0

Catch an event of child element

asked 2012-05-10 09:51:41 +0800

ccontreras gravatar image ccontreras
26 1

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

}

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2012-05-11 08:38:10 +0800

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

Mmmmmh... is there a reason why you are using SelectorComposer instead of applying a class which extends GenericForwardComposer?

link publish delete flag offensive edit

answered 2012-05-14 06:58:20 +0800

ccontreras gravatar image ccontreras
26 1

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!

link publish delete flag offensive edit

answered 2012-05-15 10:00:24 +0800

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

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

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-05-10 09:51:41 +0800

Seen: 186 times

Last updated: May 15 '12

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