Programming Tips"
m (→Composers) |
|||
Line 32: | Line 32: | ||
==Composers== | ==Composers== | ||
+ | |||
+ | If you extend from <javadoc>org.zkoss.zk.ui.util.GenericForwardComposer</javadoc> or <javadoc>org.zkoss.zk.ui.util.GenericAutowireComposer</javadoc>, you have to make sure all of its members are serializable (or transient), since the implementation will keep a reference in the applied component. | ||
+ | |||
+ | If you implement from <javadoc type="interface">org.zkoss.zk.ui.Composer</javadoc> directly, the composer could be non-serializable if you don't keep a reference in any UI object. In other words, the composer will be dropped after <javadoc method="doAfterCompose(org.zkoss.zk.ui.Component)" type="interface">org.zkoss.zk.ui.util.Composer</javadoc> | ||
=Clustering Listeners= | =Clustering Listeners= |
Revision as of 04:44, 18 November 2010
Objects Referenced by UI Must Serializable
Objects that are referenced by an UI object, such as component and page, have to be serializable. Otherwise, they might have no value after de-serialized, or causes an exception (depending how it is used).
Attributes of UI Objects
If the value of an attribute is not serializable, it will be ignored. Thus, it will become null after de-serialized. Thus, it is better to make them all serializable (such as implementing java.io.Serializable), or handle the serialization manually (refer to the Clustering Listeners section below) .
zscript
It is OK, though not recommended, to use zscript in a clustering environment, but there are some limitations.
- BeanShell's function is not serializable. For example, the following won't work:
void foo() {
}
- The values of variables must be serializable
Notice that it is not recommended to use zscript in the clustering environment. After all, the performance of BeanShell is not good.
Event Listeners
Event listeners have to be serializable. Otherwise, it will be ignored after serialization.
Data Models
The data model, such as ListModel and ChartModel, have to be serializable. Otherwise, the UI object (such as grid) won't behave correctly. The implementations provided by ZK are serializable. However, the items to be stored in the data models have to be serializable too.
Composers
If you extend from GenericForwardComposer or GenericAutowireComposer, you have to make sure all of its members are serializable (or transient), since the implementation will keep a reference in the applied component.
If you implement from Composer directly, the composer could be non-serializable if you don't keep a reference in any UI object. In other words, the composer will be dropped after Composer.doAfterCompose(Component)
Clustering Listeners
Activation Listener for Non-Serializable Objects
Serialization Listeners for Customizing Serialization
Working Thread Cannot Last Two or More Requests
Version History
Version | Date | Content |
---|---|---|