|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zkplus.databind.AnnotateDataBinderInit
public class AnnotateDataBinderInit
This initiator class do following things:
AnnotateDataBinder instance.DataBinder.loadAll() in to doAfterCompose(Page) and
initiate all UI components from the associated data bean.Put the init PI as follows:
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"
[root="component|component-path"]
[loadDefault="true|false"]
[name="binder's name"] ?>
Where the root attribute is the component itself (via EL expression) or the component path that specifies the component the AnnotateDataBinder covers. You can use absolute path that starts with "//" (search from Desktop) or "/" (search from Page); or you can use relative path(supported since ZK 3.0.8) that starts with "./" or "../" (relative to the Id Space of the page's root components). If the root attribute is not specified or set to string "page", the AnnotateDataBinder will default to cover the whole page.
Where the loadDefault attribute is used to decide whether to load default binding configuration defined in lang-addon.xml. If the loadDefault attribute is not specified it is default to true.
(since 3.6.2) Where the name attribute is used to specify the created DataBinder's name (default to "binder") which you can access it via EL or component.getVariable() later.
For application design to run ZK prior to 3.6.2, it can use arg0 instead of root, and arg1 instead of loadDefault.
AnnotateDataBinder| Field Summary | |
|---|---|
protected AnnotateDataBinder |
_binder
The AnnotateDataBinder created in doAfterCompose() |
| Constructor Summary | |
|---|---|
AnnotateDataBinderInit()
|
|
| Method Summary | |
|---|---|
void |
doAfterCompose(Page page)
Called after all components are created (aka., composed), and before any event is processed. |
void |
doAfterCompose(Page page,
Component[] comps)
Called after all components are created (aka., composed), and before any event is processed. |
boolean |
doCatch(java.lang.Throwable ex)
Called when an exception occurs during the evaluation of the page. |
void |
doFinally()
Do the cleanup after the page has been evaluated. |
void |
doInit(Page page,
java.util.Map args)
Does the initializes before the page is evaluated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected AnnotateDataBinder _binder
| Constructor Detail |
|---|
public AnnotateDataBinderInit()
| Method Detail |
|---|
public void doAfterCompose(Page page)
InitiatorNote: if InitiatorExt is also implemented,
this method won't be called. Rather, InitiatorExt.doAfterCompose(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Component[])
will be called instead.
For example, the data-binding managers could process the binding at this callback.
It won't be called if an un-caught exception occurs when creating components.
doAfterCompose in interface Initiatorpage - the page that new components are attached to. It is the same
as Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map)'s page argument.public boolean doCatch(java.lang.Throwable ex)
InitiatorIf 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.
Notice: this method won't be called if the exception occurs
in Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map).
doCatch in interface Initiatorex - the exception being thrown
public void doFinally()
InitiatorInitiator.doInit(org.zkoss.zk.ui.Page, java.util.Map) throws an exception.
However,it is always called no matter whether Initiator.doCatch(java.lang.Throwable) is called.
An exception thrown in this method is simply logged. It has no effect on the execution.
doFinally in interface Initiator
public void doInit(Page page,
java.util.Map args)
InitiatorNote: when it is called, Page.getDesktop(),
Page.getId() and Page.getTitle() all return null, since
the page is not initialized yet.
To get the current desktop, you have to use
Execution.getDesktop() (from
Executions.getCurrent()) instead.
On the other hand, you can set the page's ID, title or style in
this method (to override the declarations in the page definition)
by Page.setId(java.lang.String), Page.setTitle(java.lang.String) and Page.setStyle(java.lang.String).
In additions, Page.getRequestPath()
and Page.getAttribute(java.lang.String, int) are all available.
doInit in interface Initiatorpage - the page being evaluatedargs - a map of arguments.
Prior to 3.6.2, it is an array. To upgrade, use args.get("arg0")
instead of args[0], args.get("arg1") instead of args[1] and so on.
Of course, it is better to have a more meaningful name for
each argument.
If no argument is specified, args is an empty map (never null).
public void doAfterCompose(Page page,
Component[] comps)
throws java.lang.Exception
InitiatorExtNote: if this interface is implemented with Initiator,
Initiator.doAfterCompose(org.zkoss.zk.ui.Page) won't be called.
Rather, this method is called.
It won't be called if an un-caught exception occurs when creating components.
doAfterCompose in interface InitiatorExtpage - the page that new components are attached to. It is the same
as Initiator.doInit(org.zkoss.zk.ui.Page, java.util.Map)'s page argument.comps - the root components being created (never null, but the length
might be zero).
Note: It is not necessary the same as Page.getRoots(), since
this method might be called thru Executions.createComponents(java.lang.String, org.zkoss.zk.ui.Component, java.util.Map).
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||