-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi!
I´m starting with zkoss and i´ve a question. I´ve a zkoss window that include other window. I wanna catch the "onClick" event of the child window that have the id "btnAceptar" in the java class (GestionTest.java). What is the best thing that i can do?
Thank you very much!
This is the code of the main window:
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<window title="Test auto(FIELD_NAME1,FIELD_NAME2)" border="normal"
width="600px" apply="cliente.gestion.GestionTest">
<listbox id="resultado" vflex="true">
<listhead>
<listheader label="Full Name"
sort="auto(lastName, firstName)" />
<listheader label="Last Name" sort="auto(lastName)" />
<listheader label="Age" sort="auto(age)" />
</listhead>
<template name="model">
<listitem>
<listcell label="${each.firstName }" />
<listcell label="${each.lastName }" />
<listcell label="${each.age }" />
</listitem>
</template>
</listbox>
<button id="btnCerrar" label="cerrar"></button>
<include id="inclusion" src="botonera.zul"></include>
</window>
The code of child window
<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<button id="btnAceptar" label="aceptar"></button>
</zk>
And the code of SelectorComposer
public class GestionTest extends SelectorComposer {
@Wire
public Window ventana;
@Wire
public Button btnCerrar;
...
/*
* (non-Javadoc)
*
* @see
* org.zkoss.zk.ui.select.SelectorComposer#doAfterCompose(org.zkoss.zk.ui
* .Component)
*/
@Override
public void doAfterCompose(Component comp) throws Exception {
// TODO Auto-generated method stub
super.doAfterCompose(comp);
...
}
@Listen("onClick=#btnCerrar")
public void onClick$btnCerrar() {
Events.postEvent("onClose", ventana, null);
}
...
@Listen("onClick= #btnAceptar")
public void test() {
System.out.println("Hola");
}
}
Mmmmmh... is there a reason why you are using SelectorComposer instead of applying a class which extends GenericForwardComposer?
Hi Steva77!
I use a SelectorComposer because i´ve a listbox and i should catch the SelectEvent in the class GestionTest. I try change to a GenericForwardComposer,
but it doesn´t work.
Some idea more?
Thanks!
You should be able to catch the event in any case.
I am not sure but, since you have a window inside a window (i.e. nested components):
1. you can try and forward the event from the inner to the outer one
2. you can try and apply the GenericForwardComposer to the inner window
Hope it helps
S
Asked: 2012-05-10 09:51:41 +0800
Seen: 186 times
Last updated: May 15 '12