Package org.zkoss.clientbind
Class ClientBindComposer<T extends Component>
- java.lang.Object
-
- org.zkoss.clientbind.ClientBindComposer<T>
-
- All Implemented Interfaces:
java.io.Serializable
,AuService
,ComponentActivationListener
,Composer<T>
,ComposerExt<T>
public class ClientBindComposer<T extends Component> extends java.lang.Object implements Composer<T>, ComposerExt<T>, java.io.Serializable, AuService, ComponentActivationListener
- Author:
- jumperchen
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BEAN_UID
protected static java.lang.String
BINDER_ATTR
static java.lang.String
BINDER_ID
protected static java.lang.String
CHILDREN_ATTR
static java.lang.String
CLIENT_BINDINGS
static java.lang.String
COMMAND_EVENT
static java.lang.String
COMMAND_TRACKING_ARGUMENTS
static java.lang.String
COMMAND_TRACKING_ARGUMENTS_CHANGES
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>>
dependsOnMap
static java.lang.String
DISABLE_CLIENT_UPDATE
protected static java.lang.String
FETCH_BEAN_DATA_CMD
static java.lang.String
FORM_ATTR
protected static java.lang.String
FORM_SAVE_CMD
protected static java.lang.String
GROUP_OPEN_CMD
protected static java.lang.String
ID_ANNO
static java.lang.String
IMMUTABLE
protected static java.lang.String
INIT_ANNO
protected static java.lang.String
LIST_MODEL_SELECTION_CMD
protected static java.lang.String
LIST_SUBMODEL_CMD
protected static java.lang.String
LIST_SUBMODEL_SELECTION_CMD
static java.lang.String
LOCAL_DATE_POSTFIX
static java.lang.String
LOCAL_DATE_TIME_POSTFIX
static java.lang.String
LOCAL_TIME_POSTFIX
protected static org.slf4j.Logger
log
protected static java.lang.String
MODEL_ATTR
java.util.Map<java.lang.Object,java.lang.Integer>
modelRodSizeMap
java.util.Map<java.lang.Object,ListModel>
modelToListModel
java.util.Map<java.lang.Object,TreeModel>
modelToTreeModel
protected static java.lang.String
QUEUE_NAME_ANNO_ATTR
protected static java.lang.String
QUEUE_SCOPE_ANNO_ATTR
protected static java.lang.String
REMOTE_CLEAR_VALIDATION_MESSAGE_CMD
protected static java.lang.String
REMOTE_CMD_ARG
protected static java.lang.String
REMOTE_CONVERTER_CMD
protected static java.lang.String
REMOTE_EL_CMD
static java.lang.String
RENDER_ALL_TREE_DATA
static java.lang.String
ROD_SIZE
protected static java.lang.String
TO_STRING_CONVERTER
protected static java.lang.String
TREE_MODEL_SELECTION_CMD
protected static java.lang.String
TREEITEM_OPEN_CMD
protected static java.lang.String
UPDATE_BINDING_CMD
protected static java.lang.String
UPDATE_BINDING_DATA
protected static java.lang.String
UPDATE_SELECTION_DATA
protected static java.lang.String
VALIDATE_BINDING_CMD
protected static java.lang.String
VALIDATE_BINDING_COMPONENT_PROPERTY
protected static java.lang.String
VALIDATE_BINDING_DATA
protected static java.lang.String
VALIDATE_BINDING_PROPERTY
protected static java.lang.String
VALIDATE_SAVE_FORM_BINDING
protected static java.lang.String
VALIDATION_MESSAGE_ID
protected static java.lang.String
VALIDATION_MESSAGES_ATTR
protected static java.lang.String
VALUE_ANNO_ATTR
static java.lang.String
VIEW_MODEL_ATTR
static java.lang.String
VM_ID
static java.lang.String
WRAPPED_FORMAT_VALUE
static java.lang.String
WRAPPED_RAW_VALUE
static java.lang.String
WRAPPED_STRING_VALUE
static java.lang.String
WRAPPED_TYPE
static java.lang.String
ZONED_DATE_TIME
-
Constructor Summary
Constructors Constructor Description ClientBindComposer()
ClientBindComposer(boolean isClientWidgetOnly)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConverter(java.lang.String name, Converter converter)
protected void
clearCachedFormBeans()
protected java.lang.Object
coerceToBeanProp(java.lang.Object bean, java.lang.String prop, java.lang.Object value)
void
didActivate(Component comp)
Called when a session has just been activated (and its value has been deserialized).void
doAfterCompose(T comp)
Invokes after ZK loader creates this component, initializes it and composes all its children, if any.ComponentInfo
doBeforeCompose(Page page, Component component, ComponentInfo componentInfo)
Invokes before composing a component.void
doBeforeComposeChildren(T comp)
Invokes after the component is instantiated and initialized, but before composing any child.protected void
doBeforeComposeChildren0(T comp, java.lang.Object vmObject)
boolean
doCatch(java.lang.Throwable throwable)
Called when an exception occurs when composing the component.protected java.lang.Object
doConvertCoerceToBean(java.lang.Object origin, Component comp, java.lang.String converterExpr, java.util.Map<java.lang.String,java.lang.Object> coverterParams)
void
doFinally()
Called after the component has been composed completely.protected boolean
doValidate(java.util.Map<java.lang.String,java.lang.Object> validatorData, java.util.Map<java.lang.String,java.lang.Object> validatorProperty, java.lang.Object bean, Component comp, java.lang.String prop, java.lang.Object value)
protected java.lang.Object
evalExpression(Component target, java.lang.String expression)
protected Converter
findConverter(Component target, java.lang.String expr)
java.lang.String
getBeanUid(java.lang.Object bean)
ClientBinder
getBinder()
protected java.lang.Object
getCachedFormBeanById(java.lang.String id)
BindEvaluatorX
getEvaluatorX()
java.lang.Object
getViewModel()
void
handleModel(java.util.Map<java.lang.String,java.lang.Object> allBindings, Component comp, java.lang.String expr, java.util.Map<java.lang.String,java.lang.String[]> converterInfo)
protected void
initCachedFormBeans()
protected java.lang.Object
initInnerViewModel(BindEvaluatorX evalx, Component comp, java.lang.String vmname, java.lang.Object vm)
protected BindContext
prepareConverterContext(Component target, java.util.Map<java.lang.String,java.lang.Object> paramsFromClient)
static void
processPropertyBinding(java.util.Map<java.lang.String,java.lang.Object> allBindings, java.lang.String prop, java.lang.String annot, java.util.Map<java.lang.String,java.lang.String[]> propertyBinding)
Internal used onlystatic void
processPropertyBinding(java.util.Map<java.lang.String,java.lang.Object> allBindings, java.lang.String prop, java.lang.String annot, java.util.Map<java.lang.String,java.lang.String[]> propertyBinding, boolean multiple)
Internal used onlyvoid
renderProperties(ContentRenderer contentRenderer)
boolean
service(AuRequest request, boolean everError)
Handles an AU request.void
setCachedBeanById(java.lang.String id, java.lang.Object data)
protected void
setCachedFormBeanById(java.lang.String id, java.lang.Object data)
protected void
traverseComponentBindings(Component comp)
void
willPassivate(Component comp)
Called when a session is about to be passivated (and then serialize its value).
-
-
-
Field Detail
-
log
protected static final org.slf4j.Logger log
-
VM_ID
public static final java.lang.String VM_ID
- See Also:
- Constant Field Values
-
BINDER_ID
public static final java.lang.String BINDER_ID
- See Also:
- Constant Field Values
-
VALIDATION_MESSAGE_ID
protected static final java.lang.String VALIDATION_MESSAGE_ID
- See Also:
- Constant Field Values
-
ID_ANNO
protected static final java.lang.String ID_ANNO
- See Also:
- Constant Field Values
-
INIT_ANNO
protected static final java.lang.String INIT_ANNO
- See Also:
- Constant Field Values
-
VALUE_ANNO_ATTR
protected static final java.lang.String VALUE_ANNO_ATTR
- See Also:
- Constant Field Values
-
FORM_ATTR
public static final java.lang.String FORM_ATTR
- See Also:
- Constant Field Values
-
VIEW_MODEL_ATTR
public static final java.lang.String VIEW_MODEL_ATTR
- See Also:
- Constant Field Values
-
BINDER_ATTR
protected static final java.lang.String BINDER_ATTR
- See Also:
- Constant Field Values
-
VALIDATION_MESSAGES_ATTR
protected static final java.lang.String VALIDATION_MESSAGES_ATTR
- See Also:
- Constant Field Values
-
CHILDREN_ATTR
protected static final java.lang.String CHILDREN_ATTR
- See Also:
- Constant Field Values
-
MODEL_ATTR
protected static final java.lang.String MODEL_ATTR
- See Also:
- Constant Field Values
-
QUEUE_NAME_ANNO_ATTR
protected static final java.lang.String QUEUE_NAME_ANNO_ATTR
- See Also:
- Constant Field Values
-
QUEUE_SCOPE_ANNO_ATTR
protected static final java.lang.String QUEUE_SCOPE_ANNO_ATTR
- See Also:
- Constant Field Values
-
UPDATE_BINDING_CMD
protected static final java.lang.String UPDATE_BINDING_CMD
- See Also:
- Constant Field Values
-
UPDATE_BINDING_DATA
protected static final java.lang.String UPDATE_BINDING_DATA
- See Also:
- Constant Field Values
-
UPDATE_SELECTION_DATA
protected static final java.lang.String UPDATE_SELECTION_DATA
- See Also:
- Constant Field Values
-
VALIDATE_BINDING_CMD
protected static final java.lang.String VALIDATE_BINDING_CMD
- See Also:
- Constant Field Values
-
VALIDATE_BINDING_DATA
protected static final java.lang.String VALIDATE_BINDING_DATA
- See Also:
- Constant Field Values
-
VALIDATE_BINDING_PROPERTY
protected static final java.lang.String VALIDATE_BINDING_PROPERTY
- See Also:
- Constant Field Values
-
VALIDATE_BINDING_COMPONENT_PROPERTY
protected static final java.lang.String VALIDATE_BINDING_COMPONENT_PROPERTY
- See Also:
- Constant Field Values
-
VALIDATE_SAVE_FORM_BINDING
protected static final java.lang.String VALIDATE_SAVE_FORM_BINDING
- See Also:
- Constant Field Values
-
REMOTE_EL_CMD
protected static final java.lang.String REMOTE_EL_CMD
- See Also:
- Constant Field Values
-
REMOTE_CONVERTER_CMD
protected static final java.lang.String REMOTE_CONVERTER_CMD
- See Also:
- Constant Field Values
-
REMOTE_CMD_ARG
protected static final java.lang.String REMOTE_CMD_ARG
- See Also:
- Constant Field Values
-
FORM_SAVE_CMD
protected static final java.lang.String FORM_SAVE_CMD
- See Also:
- Constant Field Values
-
FETCH_BEAN_DATA_CMD
protected static final java.lang.String FETCH_BEAN_DATA_CMD
- See Also:
- Constant Field Values
-
REMOTE_CLEAR_VALIDATION_MESSAGE_CMD
protected static final java.lang.String REMOTE_CLEAR_VALIDATION_MESSAGE_CMD
- See Also:
- Constant Field Values
-
TREEITEM_OPEN_CMD
protected static final java.lang.String TREEITEM_OPEN_CMD
- See Also:
- Constant Field Values
-
GROUP_OPEN_CMD
protected static final java.lang.String GROUP_OPEN_CMD
- See Also:
- Constant Field Values
-
TREE_MODEL_SELECTION_CMD
protected static final java.lang.String TREE_MODEL_SELECTION_CMD
- See Also:
- Constant Field Values
-
LIST_MODEL_SELECTION_CMD
protected static final java.lang.String LIST_MODEL_SELECTION_CMD
- See Also:
- Constant Field Values
-
LIST_SUBMODEL_CMD
protected static final java.lang.String LIST_SUBMODEL_CMD
- See Also:
- Constant Field Values
-
LIST_SUBMODEL_SELECTION_CMD
protected static final java.lang.String LIST_SUBMODEL_SELECTION_CMD
- See Also:
- Constant Field Values
-
BEAN_UID
public static final java.lang.String BEAN_UID
- See Also:
- Constant Field Values
-
IMMUTABLE
public static final java.lang.String IMMUTABLE
- See Also:
- Constant Field Values
-
TO_STRING_CONVERTER
protected static final java.lang.String TO_STRING_CONVERTER
- See Also:
- Constant Field Values
-
CLIENT_BINDINGS
public static final java.lang.String CLIENT_BINDINGS
- See Also:
- Constant Field Values
-
ROD_SIZE
public static final java.lang.String ROD_SIZE
- See Also:
- Constant Field Values
-
COMMAND_EVENT
public static final java.lang.String COMMAND_EVENT
- See Also:
- Constant Field Values
-
COMMAND_TRACKING_ARGUMENTS
public static final java.lang.String COMMAND_TRACKING_ARGUMENTS
- See Also:
- Constant Field Values
-
COMMAND_TRACKING_ARGUMENTS_CHANGES
public static final java.lang.String COMMAND_TRACKING_ARGUMENTS_CHANGES
- See Also:
- Constant Field Values
-
WRAPPED_TYPE
public static final java.lang.String WRAPPED_TYPE
- See Also:
- Constant Field Values
-
WRAPPED_RAW_VALUE
public static final java.lang.String WRAPPED_RAW_VALUE
- See Also:
- Constant Field Values
-
WRAPPED_STRING_VALUE
public static final java.lang.String WRAPPED_STRING_VALUE
- See Also:
- Constant Field Values
-
WRAPPED_FORMAT_VALUE
public static final java.lang.String WRAPPED_FORMAT_VALUE
- See Also:
- Constant Field Values
-
LOCAL_DATE_POSTFIX
public static final java.lang.String LOCAL_DATE_POSTFIX
- See Also:
- Constant Field Values
-
LOCAL_DATE_TIME_POSTFIX
public static final java.lang.String LOCAL_DATE_TIME_POSTFIX
- See Also:
- Constant Field Values
-
LOCAL_TIME_POSTFIX
public static final java.lang.String LOCAL_TIME_POSTFIX
- See Also:
- Constant Field Values
-
ZONED_DATE_TIME
public static final java.lang.String ZONED_DATE_TIME
- See Also:
- Constant Field Values
-
DISABLE_CLIENT_UPDATE
public static final java.lang.String DISABLE_CLIENT_UPDATE
- See Also:
- Constant Field Values
-
RENDER_ALL_TREE_DATA
public static final java.lang.String RENDER_ALL_TREE_DATA
- See Also:
- Constant Field Values
-
dependsOnMap
public final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.util.Set<java.lang.String>>> dependsOnMap
-
modelToListModel
public final java.util.Map<java.lang.Object,ListModel> modelToListModel
-
modelToTreeModel
public final java.util.Map<java.lang.Object,TreeModel> modelToTreeModel
-
modelRodSizeMap
public final java.util.Map<java.lang.Object,java.lang.Integer> modelRodSizeMap
-
-
Method Detail
-
getEvaluatorX
public BindEvaluatorX getEvaluatorX()
-
getBinder
public ClientBinder getBinder()
-
getViewModel
public java.lang.Object getViewModel()
-
addConverter
public void addConverter(java.lang.String name, Converter converter)
-
renderProperties
public void renderProperties(ContentRenderer contentRenderer) throws java.io.IOException
- Throws:
java.io.IOException
-
doAfterCompose
public void doAfterCompose(T comp) throws java.lang.Exception
Description copied from interface:Composer
Invokes after ZK loader creates this component, initializes it and composes all its children, if any.- Specified by:
doAfterCompose
in interfaceComposer<T extends Component>
- Parameters:
comp
- the component has been composed- Throws:
java.lang.Exception
-
traverseComponentBindings
protected void traverseComponentBindings(Component comp)
-
processPropertyBinding
public static void processPropertyBinding(java.util.Map<java.lang.String,java.lang.Object> allBindings, java.lang.String prop, java.lang.String annot, java.util.Map<java.lang.String,java.lang.String[]> propertyBinding)
Internal used only
-
processPropertyBinding
public static void processPropertyBinding(java.util.Map<java.lang.String,java.lang.Object> allBindings, java.lang.String prop, java.lang.String annot, java.util.Map<java.lang.String,java.lang.String[]> propertyBinding, boolean multiple)
Internal used only
-
handleModel
public void handleModel(java.util.Map<java.lang.String,java.lang.Object> allBindings, Component comp, java.lang.String expr, java.util.Map<java.lang.String,java.lang.String[]> converterInfo)
-
doBeforeCompose
public ComponentInfo doBeforeCompose(Page page, Component component, ComponentInfo componentInfo) throws java.lang.Exception
Description copied from interface:ComposerExt
Invokes before composing a component. If you want to manipulate the specified component info, you can useComponentInfo.duplicate()
to make a copy and then modify it such that it won't affect the default behavior.- Specified by:
doBeforeCompose
in interfaceComposerExt<T extends Component>
- Parameters:
page
- the page for composing this component.component
- the parent component, or null if it is the root component.componentInfo
- the component info used to instantiate the component. Notice that it is null if the page is rendered as ZK JSP, sinceComponentInfo
is not available under ZK JSP.- Returns:
- the component info used to instantiate the component. In most case, it shall return compInfo. If null is returned, the component won't be instantiated. In other words, it is ignored.
- Throws:
java.lang.Exception
-
doBeforeComposeChildren
public void doBeforeComposeChildren(T comp) throws java.lang.Exception
Description copied from interface:ComposerExt
Invokes after the component is instantiated and initialized, but before composing any child.- Specified by:
doBeforeComposeChildren
in interfaceComposerExt<T extends Component>
- Parameters:
comp
- the component being composed- Throws:
java.lang.Exception
-
doBeforeComposeChildren0
protected void doBeforeComposeChildren0(T comp, java.lang.Object vmObject) throws java.lang.Exception
- Throws:
java.lang.Exception
-
initInnerViewModel
protected java.lang.Object initInnerViewModel(BindEvaluatorX evalx, Component comp, java.lang.String vmname, java.lang.Object vm)
-
doCatch
public boolean doCatch(java.lang.Throwable throwable) throws java.lang.Exception
Description copied from interface:ComposerExt
Called when an exception occurs when composing the component.If you don't want to handle the exception, simply returns false.
boolean doCatch(Throwable ex) {return false;}
An exception thrown in this method is simply logged. It has no effect on the execution. If you want to ignore the exception, just return true.
- Specified by:
doCatch
in interfaceComposerExt<T extends Component>
- Parameters:
throwable
- the exception being thrown- Returns:
- whether to ignore the exception. If false is returned, the exception will be re-thrown. Note: once a composer's doCatch returns true, the exception will be ignored and it means doCatch of the following composers won't be called.
- Throws:
java.lang.Exception
-
doFinally
public void doFinally() throws java.lang.Exception
Description copied from interface:ComposerExt
Called after the component has been composed completely. It is the last step of the composing.Note: it is always called even if
ComposerExt.doCatch(java.lang.Throwable)
,ComposerExt.doBeforeComposeChildren(T)
orComposer.doAfterCompose(T)
is not called (due to exceptions).Note: it is called after the onCreate event is posted, but before the onCreate and any other events are handled.
An exception thrown in this method is simply logged. It has no effect on the execution.
- Specified by:
doFinally
in interfaceComposerExt<T extends Component>
- Throws:
java.lang.Exception
-
service
public boolean service(AuRequest request, boolean everError)
Description copied from interface:AuService
Handles an AU request.- Specified by:
service
in interfaceAuService
- Parameters:
request
- the request sent from the client.everError
- whether any error ever occurred before processing this request.- Returns:
- whether the request has been processed. If false is returned, the default process (handled by the component) will take place.
-
evalExpression
protected java.lang.Object evalExpression(Component target, java.lang.String expression)
-
prepareConverterContext
protected BindContext prepareConverterContext(Component target, java.util.Map<java.lang.String,java.lang.Object> paramsFromClient)
-
doConvertCoerceToBean
protected java.lang.Object doConvertCoerceToBean(java.lang.Object origin, Component comp, java.lang.String converterExpr, java.util.Map<java.lang.String,java.lang.Object> coverterParams)
-
coerceToBeanProp
protected java.lang.Object coerceToBeanProp(java.lang.Object bean, java.lang.String prop, java.lang.Object value)
-
doValidate
protected boolean doValidate(java.util.Map<java.lang.String,java.lang.Object> validatorData, java.util.Map<java.lang.String,java.lang.Object> validatorProperty, java.lang.Object bean, Component comp, java.lang.String prop, java.lang.Object value)
-
setCachedBeanById
public void setCachedBeanById(java.lang.String id, java.lang.Object data)
-
getCachedFormBeanById
protected java.lang.Object getCachedFormBeanById(java.lang.String id)
-
setCachedFormBeanById
protected void setCachedFormBeanById(java.lang.String id, java.lang.Object data)
-
clearCachedFormBeans
protected void clearCachedFormBeans()
-
initCachedFormBeans
protected void initCachedFormBeans()
-
getBeanUid
public java.lang.String getBeanUid(java.lang.Object bean)
-
didActivate
public void didActivate(Component comp)
Description copied from interface:ComponentActivationListener
Called when a session has just been activated (and its value has been deserialized).- Specified by:
didActivate
in interfaceComponentActivationListener
-
willPassivate
public void willPassivate(Component comp)
Description copied from interface:ComponentActivationListener
Called when a session is about to be passivated (and then serialize its value).- Specified by:
willPassivate
in interfaceComponentActivationListener
-
-