0

Textbox issue

asked 2012-06-05 12:40:26 +0800

kanth gravatar image kanth
6

Hai...

I am new to zkoss. My problem is to fire a onChange event for a textbox. Here my scenario is i kept that textbox in visible="false" mode and when i click one panel that label corresponding value is filling in the textbox. At that time textbox onChange event should be fired...

Please tell me how to fire a textbox onchange event wen it is in invisible mode

Thanks in advance...
Regards...
Kanth

delete flag offensive retag edit

2 Replies

Sort by » oldest newest

answered 2012-06-05 22:10:20 +0800

twiegand gravatar image twiegand
1807 3

updated 2012-06-05 22:11:11 +0800

Kanth,

Welcome to ZK.  If I understand your scenario, I believe the issue is that the onChange event is fired when the textbox is modified from the UI.  Because you are doing this from the server side, you must manually fire the event.  Here is an example:

<zk>
	<zscript>
		import org.zkoss.zk.ui.util.GenericForwardComposer;
		
		public class myController extends GenericForwardComposer {
			
			Textbox txtbx;
			public void onClickLabel(Event event) {
				txtbx.setValue(event.getOrigin().getTarget().getValue());
				Events.sendEvent(txtbx, new Event(Events.ON_CHANGE, txtbx));  //Manually fire the onChange event
			}
			
			public void onChangeTextbox(Event event) {
				alert("Textbox onChange event received - value is: " + event.getOrigin().getTarget().getValue());
			}
		}	
	</zscript>
	<window id="win" apply="myController">

		<label value="XXXX" forward="onClick=onClickLabel"></label>
		
		<textbox id="txtbx" forward="onChange=onChangeTextbox" visible="false"></textbox>
	
	</window>
</zk>

Hope that helps,

Todd

link publish delete flag offensive edit

answered 2012-06-06 05:15:01 +0800

kanth gravatar image kanth
6

Thanks Todd....


Its absolutely working.....


U made my work easy....

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: 2012-06-05 12:40:26 +0800

Seen: 266 times

Last updated: Jun 06 '12

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