0

combobox onChange problem

asked 2009-12-12 19:24:48 +0800

ahmad gravatar image ahmad
138 1

Hi all, I am new with zk, I am using ZK SDK version "zk-bin-ent-5.0.0-RC2", I am facing a problem with combobox, here is snaps of my code:

1 - zul page:

<zk>
<window use="com.MyWindow" id="win">
.....
<combobox ...... onChange="win.doSomething()"/>
.....
</window>
</zk>

2 - Java class

package com;
.....

public class MyWindow extends Window
{
.......
public void doSomething()
{
.............
}
}

the problem is that when I change the selected item in my combobox, the desired method

doSomething()
not fired at all.
I need to know why.
Thank you for Concern.
Ahmad Elsafty

delete flag offensive retag edit

14 Replies

Sort by ยป oldest newest

answered 2009-12-13 04:38:01 +0800

samchuang gravatar image samchuang
4084 4

Hi ~
event is not using like that, you could look at the small talk here

link publish delete flag offensive edit

answered 2009-12-13 08:13:33 +0800

ahmad gravatar image ahmad
138 1

Thank you "samchuang", for reply.
I will read and try this small talk.
Thanks again.
Ahmad Elsafty

link publish delete flag offensive edit

answered 2009-12-13 17:46:32 +0800

ahmad gravatar image ahmad
138 1

Thank you "samchuang", for this tutorial.
And of course many thanks to ZK team for this great event handling technique.
Ahmad Elsafty.

link publish delete flag offensive edit

answered 2009-12-13 18:45:54 +0800

ahmad gravatar image ahmad
138 1

Sorry "samchuang", I tried this tutorial, it works fine with ZK SDK versions "zk-bin-3.6.6" and "zk-bin-5.0.0-RC", but does not work at all with ZK SDK version "zk-ent-bin-5.0.0-RC".
I can not know why.
Thank you for Concern.
Ahmad Elsafty

link publish delete flag offensive edit

answered 2009-12-13 19:02:47 +0800

samchuang gravatar image samchuang
4084 4

Hi ~~

Could you provide sample code for test?? zul and java

link publish delete flag offensive edit

answered 2009-12-13 22:17:04 +0800

ahmad gravatar image ahmad
138 1

Hi "samchuang".
1 - zul code:

                                          <h:table>
						<h:tr>
							<h:td width="460" />
							<h:td width="57">
								<combobox id="lengthTo" width="57" />
							</h:td>
							<h:td width="48" />
							<h:td width="57">
								<combobox id="lengthFrom" width="57" />
							</h:td>
							<h:td />
						</h:tr>
					</h:table>

2 - Java code:

@Override
class MyComposer implements Composer{
	public void doAfterCompose(final Component comp) throws Exception {
		
		EventListenerUtil.setup(comp, this);
	}

	public void onChange$LengthFrom(Event e) {
		findProducts(e.getTarget().getRoot());
	}

	public void onChange$lengthTo(Event e) {
		findProducts(e.getTarget().getRoot());
	}

	public void findProducts(Component comp) {
		System.out.println("inside search method");
}
}

And due to EventListenerUtil class, I have copied it from the tutorial you sent before.
****************
The prvious code does not work with SDK version I told you before, but when I use the regular method to add Listener:

comp.getFellow("hpCombo").addEventListener("onChange", new EventListener() {
            public void onEvent(Event event) throws Exception {
            	findProducts(comp);

it works fine with all SDK versions.
Thanks again.
Ahmad Elsafty

link publish delete flag offensive edit

answered 2009-12-14 15:53:17 +0800

ahmad gravatar image ahmad
138 1

Hi all, Is there any response for my last question?
Thanks for Concern.
Ahmad Elsafty

link publish delete flag offensive edit

answered 2009-12-14 18:37:03 +0800

samchuang gravatar image samchuang
4084 4

Hi~~

the code in your post is right, do you have any more problem ?

comp.getFellow("hpCombo").addEventListener("onChange", new EventListener() {
            public void onEvent(Event event) throws Exception {
            	findProducts(comp);

link publish delete flag offensive edit

answered 2009-12-14 19:20:38 +0800

ahmad gravatar image ahmad
138 1

I do not have any problems with this code:

comp.getFellow("hpCombo").addEventListener("onChange", new EventListener() {
            public void onEvent(Event event) throws Exception {
            	findProducts(comp);
}});

but the other method of assigning handler does not work:

class MyComposer implements Composer{
	public void doAfterCompose(final Component comp) throws Exception {
		
		EventListenerUtil.setup(comp, this);
	}

	public void onChange$LengthFrom(Event e) {
		findProducts(e.getTarget().getRoot());
	}

	public void onChange$lengthTo(Event e) {
		findProducts(e.getTarget().getRoot());
	}

	public void findProducts(Component comp) {
		System.out.println("inside search method");
}
}

Then I will replace the

onXxx$compId
with the classic one.
Thank you "samchuang" very much for your Concern.
Ahmad Elsafty.

link publish delete flag offensive edit

answered 2009-12-14 21:10:21 +0800

samchuang gravatar image samchuang
4084 4

Hi ~~

Do you mean EventListenerUtil. setup() will cause problem??

I find a another wiki about using Composer, link

I always use "MyComposer5.java" example in my code, it save a log of coding, the idea is the same as you using EventListenerUtil;

Hope this will help you~~

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: 2009-12-12 19:24:48 +0800

Seen: 2,163 times

Last updated: Dec 16 '09

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