参考API:
https://www.zkoss.org/javadoc/latest/zk/
Demo:
A skeletal composer that you can extend and write intuitive onXxx$myid event handler methods with auto event forwarding and "auto-wired" accessible variable objects such as embedded objects, components, and external resolvable variables in a ZK zuml page; this class will add forward condition to the myid source component and forward source onXxx event received by the source myid component to the target onXxx$myid event (as defined in this composer) of the supervised target component; of course it will also registers onXxx$myid events to the supervised component and wire all accessible variable objects to this composer by calling setXxx() method or set xxx field value directly per the variable name.
MyComposer.java
public class MyComposer extends GenericForwardComposer {
private Textbox mytextbox;
private Window self; //embedded object, the supervised window "mywin"
private Page page; //the ZK zuml page
private Label mylabel;
public void onChange$mytextbox(Event event) {
mylabel.setValue("You just entered: "+ mytextbox.getValue());
}
}
test.zul
<window id="mywin" apply="MyComposer">
<textbox id="mytextbox"/>
<label id="mylabel"/>
</window>
主要方法:
doAfterCompose(T comp)
Auto forward events and wire accessible variables of the specified component into a controller Java object; a subclass that override this method should remember to call super.doAfterCompose(comp) or it will not work.