-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello everybody out there,
I have a problem getting the right target component when catching the onClick event.
My page is composed of a listbox (see below).
<zul:div id="taskBoardViewFragment" class="section" self="@{define(content) fragment(taskBoardViewFragment)}"> <zul:borderlayout height="420px"> <zul:north maxsize="200" size="100%" splittable="true" autoscroll="true" > <zul:listbox id="storyList" height="400px" multiple="true" apply="${taskBoardCtrl}"> <zul:listhead> <zul:listheader hflex="1" label="stories" /> <zul:listheader hflex="1" label="not started" /> <zul:listheader hflex="1" label="in progress" /> <zul:listheader hflex="1" label="done" /> </zul:listhead> </zul:listbox> </zul:north> </zul:borderlayout> </zul:div>
The glued composer is catching the onClick event and sets the model and the ItemRenderer.
@Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); //create model storyList.setModel(new ListModelList(storyService.getAllStories())); //create renderer storyList.setItemRenderer(new StoryListRenderer()); }
The listitems are composd in a ListItenRenderer (see below). The listitems has
panel components as children.
public class StoryListRenderer implements ListitemRenderer { @Override public void render(Listitem item, Object data) throws Exception { // Das Panel für die Story zusammenbauen Story story = (Story) data; Panel storyPanel = new Panel(); storyPanel.setTitle(story.getTitel()); Panelchildren storyPanelChild = new Panelchildren(); storyPanel.appendChild(storyPanelChild); Textbox storyTxtbox = new Textbox(story.getDescription()); storyTxtbox.setWidth("100%"); storyTxtbox.setMultiline(true); storyPanelChild.appendChild(storyTxtbox); Listcell lc = new Listcell(); lc.appendChild(storyPanel); item.appendChild(lc); // Die zugehörigen Aufgaben im Status "not started" ermitteln Set<Task> tasks = story.getTasks(); Iterator<Task> it = tasks.iterator(); Vbox vboxNotStartedTasks = new Vbox(); Vbox vboxInProgressTasks = new Vbox(); Vbox vboxDoneTasks = new Vbox(); while (it.hasNext()) { Task task = it.next(); Textbox taskTxtbox = new Textbox(task.getDescription()); taskTxtbox.setWidth("100%"); taskTxtbox.setMultiline(true); Panelchildren taskPanelChild = new Panelchildren(); taskPanelChild.appendChild(taskTxtbox); Panel taskPanel = new Panel(); taskPanel.setTitle(task.getTitel()); taskPanel.appendChild(taskPanelChild); taskPanel.setDraggable("true"); taskPanel.setId(Long.valueOf(task.getId()).toString()); if (task.getStatus().equals("not started")) { vboxNotStartedTasks.appendChild(taskPanel); } else if(task.getStatus().equals("in progress")) { vboxInProgressTasks.appendChild(taskPanel); } else if(task.getStatus().equals("done")) { vboxDoneTasks.appendChild(taskPanel); } } Listcell lstcellNotStartedTasks = new Listcell(); lstcellNotStartedTasks.appendChild(vboxNotStartedTasks); item.appendChild(lstcellNotStartedTasks); Listcell lstcellInProgressTasks = new Listcell(); lstcellInProgressTasks.appendChild(vboxInProgressTasks); item.appendChild(lstcellInProgressTasks); Listcell lstcellDoneTasks = new Listcell(); lstcellDoneTasks.appendChild(vboxDoneTasks); item.appendChild(lstcellDoneTasks); }
Now the question:
If I click a panel in the listbox I like to get the panel if I call event.getTarget() in the onClick method.
Unfortunatelly I get the listbox itself. Any suggestions?
Thanks in advanced. Christian
Asked: 2011-11-29 09:11:47 +0800
Seen: 144 times
Last updated: Nov 30 '11