org.zkoss.zk.ui.util
Class GenericForwardComposer

java.lang.Object
  extended by org.zkoss.zk.ui.event.GenericEventListener
      extended by org.zkoss.zk.ui.util.GenericComposer
          extended by org.zkoss.zk.ui.util.GenericAutowireComposer
              extended by org.zkoss.zk.ui.util.GenericForwardComposer
All Implemented Interfaces:
java.io.Serializable, EventListener, ComponentActivationListener, ComponentCloneListener, Composer, ComposerExt

public abstract class GenericForwardComposer
extends GenericAutowireComposer

An abstract 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.

Notice that since this composer kept references to the components, single instance object cannot be shared by multiple components.

The following is an example. The onChange event received by Textbox mytextbox will be forwarded to target Window mywin as a new target event onChange$mytextbox and the Textbox component with id name "mytextbox" and Label with id name mylabel are injected into the "mytextbox" and "mylabel" fields respectively(so you can use mytextbox and mylabel variable directly in onChange_mytextbox without problem).


 MyComposer.java
 
 public class MyComposer extends GenericForwardComposer {
     private Textbox mytextbox;
     private Window self; //embeded 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>
 

Since:
3.0.7
Author:
henrichen
See Also:
Components.addForwards(org.zkoss.zk.ui.Component, java.lang.Object), Serialized Form

Field Summary
 
Fields inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
_separator, application, applicationScope, arg, componentScope, desktop, desktopScope, execution, page, pageScope, param, requestScope, self, session, sessionScope, spaceOwner, spaceScope
 
Fields inherited from class org.zkoss.zk.ui.util.GenericComposer
_applied
 
Constructor Summary
protected GenericForwardComposer()
           
protected GenericForwardComposer(char separator)
          Constructor with a custom separator.
 
Method Summary
 void doAfterCompose(Component 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.
 
Methods inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
alert, didActivate, willClone
 
Methods inherited from class org.zkoss.zk.ui.util.GenericComposer
doBeforeCompose, doBeforeComposeChildren, doCatch, doFinally, willPassivate
 
Methods inherited from class org.zkoss.zk.ui.event.GenericEventListener
bindComponent, getController, onEvent, unbindComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.zkoss.zk.ui.util.ComponentActivationListener
willPassivate
 

Constructor Detail

GenericForwardComposer

protected GenericForwardComposer()

GenericForwardComposer

protected GenericForwardComposer(char separator)
Constructor with a custom separator. The separator is used to separate the component ID and event name. By default, it is '$'. For Grooy and other environment that '$' is not applicable, you can specify '_'.

Since:
3.6.0
Method Detail

doAfterCompose

public void doAfterCompose(Component comp)
                    throws java.lang.Exception
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.

Specified by:
doAfterCompose in interface Composer
Overrides:
doAfterCompose in class GenericAutowireComposer
Parameters:
comp - the component has been composed
Throws:
java.lang.Exception


Copyright © 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo