Package org.zkoss.zk.ui.util
Interface Composer<T extends Component>
-
- All Known Implementing Classes:
GenericAutowireComposer,GenericComposer,GenericForwardComposer,MultiComposer,SelectorComposer
public interface Composer<T extends Component>Represents a composer to initialize a component (or a component of tree) when ZK loader is composing a component. It is the controller in the MVC pattern, while the component is the view.To initialize a component, you can implement this interface and then specify the class or an instance of it with the apply attribute as follows.
<window apply="my.MyComposer"/> <window apply="${a_composer}"/>Then, ZK loader will
- Invoke
ComposerExt.doBeforeCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.metainfo.ComponentInfo), if the composer also implementsComposerExt. - Create the component (by use of
UiFactory.newComponent(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.metainfo.ComponentInfo, org.zkoss.zk.ui.Component), which creates and initializes the component accordingly). - Invokes
ComposerExt.doBeforeComposeChildren(T), ifComposerExtis also implemented. - Composes all children, if any, of this component defined in the ZUML page.
- Invokes
doAfterCompose(T)after all children are, if any, composed. - Posts the onCreate event if necessary.
To intercept the lifecycle of the creation of a page, implement
Initiatorand specify the class with the init directive.Note:
AfterComposehas to be implemented as part of a component, whileComposeris a controller used to initialize a component (that might or might not implementAfterCompose).Alternatives: in most cases, you don't implement
Composerdirectly. Rather, you can extend from one of the following skeletons.SelectorComposer- It supports the autowiring based on Java annotation and a CSS3-based selector.
If you don't know which one to use, use
SelectorComposer. GenericForwardComposer- It supports the autowiring based on naming convention. You don't need to specify annotations explicitly, but it is error-prone if it is used properly.
- Since:
- 3.0.0
- Author:
- tomyeh
- See Also:
AfterCompose,ComposerExt,FullComposer,Initiator
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddoAfterCompose(T comp)Invokes after ZK loader creates this component, initializes it and composes all its children, if any.
-
-
-
Method Detail
-
doAfterCompose
void doAfterCompose(T comp) throws java.lang.Exception
Invokes after ZK loader creates this component, initializes it and composes all its children, if any.- Parameters:
comp- the component has been composed- Throws:
java.lang.Exception
-
-