Package org.zkoss.bind
Class BindComposer<T extends Component>
- java.lang.Object
-
- org.zkoss.bind.BindComposer<T>
-
- All Implemented Interfaces:
java.io.Serializable,AuService,ComponentActivationListener,Composer<T>,ComposerExt<T>
public class BindComposer<T extends Component> extends java.lang.Object implements Composer<T>, ComposerExt<T>, java.io.Serializable, AuService, ComponentActivationListener
Base composer to apply ZK Bind.- Since:
- 6.0.0
- Author:
- henrichen
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringBINDER_ATTRstatic java.lang.StringBINDER_IDprotected static java.lang.StringID_ANNOprotected static java.lang.StringINIT_ANNOstatic java.lang.StringON_BIND_COMMANDstatic java.lang.StringON_BIND_COMMAND_UPLOADstatic java.lang.StringON_BIND_GLOBAL_COMMANDprotected static java.lang.StringQUEUE_NAME_ANNO_ATTRprotected static java.lang.StringQUEUE_SCOPE_ANNO_ATTRprotected static java.lang.StringVALIDATION_MESSAGES_ATTRprotected static java.lang.StringVALUE_ANNO_ATTRprotected static java.lang.StringVIEW_MODEL_ATTRstatic java.lang.StringVM_ID
-
Constructor Summary
Constructors Constructor Description BindComposer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConverter(java.lang.String name, Converter converter)voidaddValidator(java.lang.String name, Validator validator)voiddidActivate(Component comp)Called when a session has just been activated (and its value has been deserialized).voiddoAfterCompose(T comp)Invokes after ZK loader creates this component, initializes it and composes all its children, if any.ComponentInfodoBeforeCompose(Page page, Component parent, ComponentInfo compInfo)Invokes before composing a component.voiddoBeforeComposeChildren(Component comp)Invokes after the component is instantiated and initialized, but before composing any child.booleandoCatch(java.lang.Throwable ex)Called when an exception occurs when composing the component.voiddoFinally()Called after the component has been composed completely.BindergetBinder()ConvertergetConverter(java.lang.String name)ValidatorgetValidator(java.lang.String name)java.lang.ObjectgetViewModel()voidnotifyChange(java.lang.Object bean, java.lang.String property)booleanservice(AuRequest request, boolean everError)Handles an AU request.voidsetViewModel(java.lang.Object viewModel)voidwillPassivate(Component comp)Called when a session is about to be passivated (and then serialize its value).
-
-
-
Field Detail
-
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
-
ON_BIND_COMMAND
public static final java.lang.String ON_BIND_COMMAND
- See Also:
- Constant Field Values
-
ON_BIND_GLOBAL_COMMAND
public static final java.lang.String ON_BIND_GLOBAL_COMMAND
- See Also:
- Constant Field Values
-
ON_BIND_COMMAND_UPLOAD
public static final java.lang.String ON_BIND_COMMAND_UPLOAD
- 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
-
VIEW_MODEL_ATTR
protected 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
-
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
-
-
Method Detail
-
getBinder
public Binder getBinder()
-
setViewModel
public void setViewModel(java.lang.Object viewModel)
-
getViewModel
public java.lang.Object getViewModel()
-
getConverter
public Converter getConverter(java.lang.String name)
-
getValidator
public Validator getValidator(java.lang.String name)
-
addConverter
public void addConverter(java.lang.String name, Converter converter)
-
addValidator
public void addValidator(java.lang.String name, Validator validator)
-
doBeforeCompose
public ComponentInfo doBeforeCompose(Page page, Component parent, ComponentInfo compInfo) throws java.lang.Exception
Description copied from interface:ComposerExtInvokes 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:
doBeforeComposein interfaceComposerExt<T extends Component>- Parameters:
page- the page for composing this component.parent- the parent component, or null if it is the root component.compInfo- the component info used to instantiate the component. Notice that it is null if the page is rendered as ZK JSP, sinceComponentInfois 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(Component comp) throws java.lang.Exception
Description copied from interface:ComposerExtInvokes after the component is instantiated and initialized, but before composing any child.- Specified by:
doBeforeComposeChildrenin interfaceComposerExt<T extends Component>- Parameters:
comp- the component being composed- Throws:
java.lang.Exception
-
doAfterCompose
public void doAfterCompose(T comp) throws java.lang.Exception
Description copied from interface:ComposerInvokes after ZK loader creates this component, initializes it and composes all its children, if any.- Specified by:
doAfterComposein interfaceComposer<T extends Component>- Parameters:
comp- the component has been composed- Throws:
java.lang.Exception
-
doCatch
public boolean doCatch(java.lang.Throwable ex) throws java.lang.ExceptionDescription copied from interface:ComposerExtCalled 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:
doCatchin interfaceComposerExt<T extends Component>- Parameters:
ex- 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.ExceptionDescription copied from interface:ComposerExtCalled 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:
doFinallyin interfaceComposerExt<T extends Component>- Throws:
java.lang.Exception
-
notifyChange
public void notifyChange(java.lang.Object bean, java.lang.String property)
-
didActivate
public void didActivate(Component comp)
Description copied from interface:ComponentActivationListenerCalled when a session has just been activated (and its value has been deserialized).- Specified by:
didActivatein interfaceComponentActivationListener
-
willPassivate
public void willPassivate(Component comp)
Description copied from interface:ComponentActivationListenerCalled when a session is about to be passivated (and then serialize its value).- Specified by:
willPassivatein interfaceComponentActivationListener
-
service
public boolean service(AuRequest request, boolean everError)
Description copied from interface:AuServiceHandles an AU request.- Specified by:
servicein 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.
-
-