# Can I have multiple extension of AnnotateDataBinderInit for different zul pages?

asked 2010-04-05 16:37:56 +0800

lukexma
15

I have two classes that extend AnnotateDataBinderInit classe. I do not want to use zscripts. I want to do it MVC way:

public class PersonInit
extends AnnotateDataBinderInit
{
}

public class StockInit
extends AnnotateDataBinderInit
{
}

The server gives me this exception:
org.zkoss.zk.ui.UiException: Page is already covered by another Data Binder. Cannot be covered by this Data Binder again. Page:LayoutPageId

If I have only one extension of AnnotateDataBinderInit, and do all the initialization in the one class, it works OK. Is there a way to have multiple classes that extends AnnotateDataBinderInit for different zul pages?

delete retag edit

## 4 Replies

Sort by » oldest newest

answered 2010-04-05 19:56:54 +0800

937 2 12

This error means that both person and stock binders are handling the same component.

As far as I remember, you can use both, but have to specify the root component for each, and make sure they're not interlacing.

Pseudo code not tested warning:

<?init class="databind.PersonInit" arg0="./pnlPersons" ?>
<?init class="databind.StockInit" arg0="./pnlStocks" ?>

<window>
<panel id="pnlPersons"> components here </panel>
<panel id="pnlStocks"> components here </panel>
</window>


answered 2010-04-05 23:53:32 +0800

lukexma
15

Thank you for your response. I did this in two zul files. It still trows the same exception.

Frankly speaking, learning ZK is one of the most frustrating experience to me. I don't know other people's experience. When putting ZK into production stage, it's even more frustrating: The feeling that the teams have been cheated by the sellers.

answered 2010-04-06 07:34:51 +0800

937 2 12

Based on the error message: "Cannot be covered by this Data Binder again. Page:LayoutPageId", both binder are covering the Page component, which is the root component, so the arg0="component" is not really working, and the binder is then attaching itself in the page instead of the component. I would put some break points on the binder init class, and really see what's going on in the background.

For your other comment, I believe that the data binding part of ZK is probably the most complex part, the part the most of us will struggle a bit. But even with all this complexity, I think that ZK is far more easier and intuitive than others web frameworks. I really don't think that our team would have a better productivity rate with other web ui framework.

answered 2010-04-06 10:05:12 +0800

robertpic71
1275 1

Hi,

1.)

meanwhile, i prefer to create my own databinder-instance.

Here is some code form my standard-controller:

@Repository("mainController")
@Scope("prototype")
public class Main extends GenericForwardComposer {

private AnnotateDataBinder binder;
...
/*
* Model und Servicedata
*/

MainModel model;

@Override
public void doAfterCompose(Component _win) throws Exception {
super.doAfterCompose(_win);
win.setVariable("model", model, false);  // make models visible for the databinder [1]
binder = new AnnotateDataBinder(_win);
...
}


[1] Since ZK 5.0.0 you should setAttribute instead

Note: There is no <?init..> inside my zul.

2.) 2 binders for the same data
I've not tested this, maybe it works. However i do not need this, because it is possible to scope the databinder.

i.e.
<grid id="input">
<rows>
<row>* Lastname: <textbox id="lastname" value="@{model.PersonBean.lastname}" constraint="no empty" width="300px" /></row>
<row>* Firstname: <textbox id="firstname" value="@{model.PersonBean.firstname}" constraint="no empty" width="300px"/></row>
....
</rows>
<textbox id="other" value="@{model.CityBean.name}"/>
...

2a.)

load all Elements under "input", because "other" is outside "input" it will be not loaded!

2b.)

2c.) of course, this works for binder.saveComponent() also

3.) For new windows, create a new databinder - no troubles at all

/Robert

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

## Stats

Asked: 2010-04-05 16:37:56 +0800

Seen: 533 times

Last updated: Apr 06 '10

## Related questions

Support Options
• Email Support
• Training
• Consulting
• Outsourcing