-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi guys, I have a problem about ZK's DataBinder. In fact I've spent a lot of time on it and still have no progress,
I hope some guy here can help me and any help would be appreciate.
Ok, see the source code below first:
list_task.zul(Data Binder is needed in this zul)
<?page id="list_task" ?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <zk> <window id="ListTaskWindow" border="normal" xmlns:a="http://www.zkoss.org/2005/zk/annotation" apply="com.kiyozawa.easp.calendar.ui.controller.task.ListTaskController"> <listbox id="TaskList" multiple="true" context="editPopup"> // Data Binding Code </listbox> <button label="Create"> <attribute name="onClick"> Window win = (Window)Executions.getCurrent().createComponents("/zul/task/add_edit_task.zul" , null, null); win.doModal(); </attribute> </button> </window> </zk>
add_edit_task.zul(Data Binding is also needed in this zul)
<?page id="add_edit_task" ?> <window id="AddEditTaskWindow" border="normal" closable="true" xmlns:h="http://www.w3.org/1999/xhtml" apply="com.kiyozawa.easp.calendar.ui.controller.task.AddEditTaskController"> <grid> <columns> <column width="30%" /> <column /> </columns> <rows> <row> <hbox> <label value="task name :" /> </hbox> <textbox id="taskName" width="98%" value="@{AddEditTaskWindow$AddEditTaskController.name}" /> </row> <row> <label value="description: " /> <textbox id = "textbox" rows="5" width="98%" value="@{AddEditTaskWindow$AddEditTaskController.description}"/> </row> <row spans="2" align="center"> <hbox> <button label="create"> </button> <button label="cancel"> </button> </hbox> </row> </rows> </grid> </window>
Now you see, add_edit_task.zul was created by Executions.getCurrent().createComponents() in list_task.zul .
After it was created, add_edit_task.zul and list_task.zul belongs to the same page, so that they will share
one data binder !
Two zul pages share one data binder can bring some problems, like you can not use binder.loadAll, cause it
will affect two pages
So my question is : is it possible to let add_edit_task.zul have a different data binder? how to do it?
>> is it possible to let add_edit_task.zul have a different data binder? how to do it?
Check the API and the onlinedemo / databinding.
Variant 1: You could pass the arg0 to the databinderinit --> store component, default is desktop!
i.e.
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./AddEditTaskWindow"?>
Variant 2:
Do not use init class, setup you databinder the composer/aftercompose. I'll post code later.
/Robert
Here is the code:
Remove the init and setup add code like this in the afterCompose:
// store the databinder for later extra load and save
binder = new AnnotateDataBinder(win);
binder.bindBean("controller", this); // bind this controller to the databinder
binder.loadAll();
and change your bindings to @{controller... or what you want.
/Robert
Asked: 2009-05-12 03:10:15 +0800
Seen: 721 times
Last updated: Dec 20 '11