-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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()
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
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);
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);
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
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~~
Asked: 2009-12-12 19:24:48 +0800
Seen: 2,163 times
Last updated: Dec 16 '09