-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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>
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.
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.
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); ... }
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.)
binder.loadComponent(input);
load all Elements under "input", because "other" is outside "input" it will be not loaded!
2b.)
binder.loadAll();
load all Elements
2c.) of course, this works for binder.saveComponent() also
3.) For new windows, create a new databinder - no troubles at all
/Robert
Asked: 2010-04-05 16:37:56 +0800
Seen: 533 times
Last updated: Apr 06 '10