0

How to get Textbox value which is child of Listcell?????

asked 2011-04-14 07:39:08 +0800

drishtisv gravatar image drishtisv
135 2


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) ?

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2011-04-15 03:28:49 +0800

drishtisv gravatar image drishtisv
135 2

Hi all gurus

Is it possible to get Value textbox which is child of listcell?

link publish delete flag offensive edit

answered 2011-04-15 06:26:01 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

>> 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.

link publish delete flag offensive edit

answered 2011-04-15 08:04:37 +0800

drishtisv gravatar image drishtisv
135 2

Hi Steva

Thanks for suggested thread. I read but not get any clue.

link publish delete flag offensive edit

answered 2011-04-15 08:45:23 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

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();
}

once you know which event you are coping with.
Sorry, I am still not such an expert to post immediately a great solution.... ;)

link publish delete flag offensive edit

answered 2011-04-16 00:43:52 +0800

drishtisv gravatar image drishtisv
135 2

Problem solved

Listcell listcell = (Listcell) item.getChildren().get(7);
((Textbox)listcell.getChildren().get(0)).getValue();

will get a value of TextBox

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-04-14 07:39:08 +0800

Seen: 634 times

Last updated: Apr 16 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More