-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have to create textboxes dynamically in ListBox. But I unable to get value of Textbox. Following is the code. Listcell cell=new Listcell(); Listcell cell2=new Listcell(); Button b1=new Button(); b1.setLabel("Schedule"); b1.addEventListener("onClick", new ClickListener(li)); b1.setParent(cell); li.appendChild(cell); Textbox t1=new Textbox(); t1.setValue("@{unit_c.itemunitcode}"); t1.setParent(cell2); li.appendChild(cell2); lst_reqitems.appendChild(li); ...... ..... import org.zkoss.zk.ui.event.EventListener; final class ClickListener implements EventListener { Listitem item; ClickListener(Listitem selitem) { item=selitem; } public void onEvent(Event event) throws UiException { try{ alert("generated..."+item.getChildren().get(1).getLabel()); setreq_items(item); } catch(Exception e) { //System.out.println("Error plz select proper item "+e); alert("Error plz select proper item "+e); } } }
When I click button (b1) I require value of t1 (Textbox) ?
>> Is it possible to get Value textbox which is child of listcell?
I'd say sure you can.
Have a look also at this thread.
I usually catch events in a controller class extending GenericForwardComposer.
It was an hint on trying out something similar to:
public static Component getEventTarget(Event event) { if (event instanceof ForwardEvent) { return ((ForwardEvent)event).getOrigin().getTarget(); } return event.getTarget(); }
Asked: 2011-04-14 07:39:08 +0800
Seen: 634 times
Last updated: Apr 16 '11