The org.zkoss.zk.ui.util.Composer interface"

From Documentation
m ((via JWB))
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
  {{ZKConfigurationReferencePageHeader}}
 
  {{ZKConfigurationReferencePageHeader}}
'''Property:'''
 
The org.zkoss.zk.ui.util.Composer interface
 
  
 +
'''Listener:'''
 +
org.zkoss.zk.ui.util.Composer
  
[since 5.0.1]
+
{{versionSince|5.0.1}}
  
<javadoc type="interface">org.zkoss.zk.ui.util.Composer</javadoc> is implemented by a listener class that can process the creation of ZK pages like a composer specified in the <tt>apply</tt> attribute. It is also known as ''system-level composers''.
+
A listener could implement <javadoc type="interface">org.zkoss.zk.ui.util.Composer</javadoc>, such that it can process the creation of ZK pages like a composer specified in [[ZUML Reference/ZUML/Attributes/apply|the apply attribute]]. It is also known as ''system-level composers''.
  
Each time a ZK page, including ZK pages and richlets, is created, ZK will instantiate one instance for each registered system-level composer and the invoke the <tt>doAfterCompose</tt> method with each root component. The system-level composer is usually used to post-process ZK pages, such as adding a trademark. If you want to process only certain pages, you can check the request path by calling <javadoc method="getRequestPath()" type="interface">org.zkoss.zk.ui.Desktop</javadoc> (the desktop instance can be found thru the give component).
+
Each time a ZK page, including ZK pages and richlets, is created, ZK will instantiate one instance for each registered system-level composer and then invoke <javadoc method="doAfterCompose(org.zkoss.zk.ui.Component)" type="interface">org.zkoss.zk.ui.util.Composer</javadoc> with each root component. The system-level composer is usually used to post-process ZK pages, such as adding a trademark. If you want to process only certain pages, you can check the request path by calling <javadoc method="getRequestPath()" type="interface">org.zkoss.zk.ui.Desktop</javadoc> (the desktop instance can be found in the given component).
  
 
If the system-level composer also implements <javadoc type="interface">org.zkoss.zk.ui.util.ComposerExt</javadoc>, it can be used to handle more situations, such as exceptions, like any other composer can do.
 
If the system-level composer also implements <javadoc type="interface">org.zkoss.zk.ui.util.ComposerExt</javadoc>, it can be used to handle more situations, such as exceptions, like any other composer can do.
Line 18: Line 18:
 
:'''Richlet'''
 
:'''Richlet'''
  
:The system-level composers are applied to richlets too. In additions, a system-level composer can implement <javadoc type="interface">org.zkoss.zk.ui.util.ComposerExt</javadoc> to handle exceptions for a richlet, such as <tt>doCatch</tt> and <tt>doFinally</tt>. However, <tt>doBeforeCompose</tt> and <tt>doBeforeComposeChildren</tt>  won't be called.
+
:The system-level composers are applied to richlets too. In addition, a system-level composer can implement <javadoc type="interface">org.zkoss.zk.ui.util.ComposerExt</javadoc> to handle exceptions for a richlet, such as <code>doCatch</code> and <code>doFinally</code>. However, <code>doBeforeCompose</code> and <code>doBeforeComposeChildren</code>  won't be called.
  
 
:<javadoc type="interface">org.zkoss.zk.ui.util.FullComposer</javadoc> is not applicable to richlets. In other words, system-level composers are called only for the root components.
 
:<javadoc type="interface">org.zkoss.zk.ui.util.FullComposer</javadoc> is not applicable to richlets. In other words, system-level composers are called only for the root components.
  
{{ZKConfigurationReferencePageFooter}}
+
'''Instantiation:'''
 +
An independent instance of the given class is instantiated each time before the method is invoked. It means it is thread safe, and all information stored in non-static members will be lost after called.
 +
 
 +
{{ZKConfigurationReferencePageFooter}}

Latest revision as of 09:34, 14 March 2022


The org.zkoss.zk.ui.util.Composer interface


Listener:

org.zkoss.zk.ui.util.Composer

Since 5.0.1

A listener could implement Composer, such that it can process the creation of ZK pages like a composer specified in the apply attribute. It is also known as system-level composers.

Each time a ZK page, including ZK pages and richlets, is created, ZK will instantiate one instance for each registered system-level composer and then invoke Composer.doAfterCompose(Component) with each root component. The system-level composer is usually used to post-process ZK pages, such as adding a trademark. If you want to process only certain pages, you can check the request path by calling Desktop.getRequestPath() (the desktop instance can be found in the given component).

If the system-level composer also implements ComposerExt, it can be used to handle more situations, such as exceptions, like any other composer can do.

If the system-level composer also implements FullComposer, it will be invoked when each component is created. It provides the finest grain of control but a wrong implementation might degrade the performance.

Notice that since a new instance of the composer is created for each page, there is no threading issues.

Richlet
The system-level composers are applied to richlets too. In addition, a system-level composer can implement ComposerExt to handle exceptions for a richlet, such as doCatch and doFinally. However, doBeforeCompose and doBeforeComposeChildren won't be called.
FullComposer is not applicable to richlets. In other words, system-level composers are called only for the root components.

Instantiation: An independent instance of the given class is instantiated each time before the method is invoked. It means it is thread safe, and all information stored in non-static members will be lost after called.



Last Update : 2022/03/14

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.