0

Can I have a different DataBinder in a dialog window created by Execution.createComponents(...) ?

asked 2009-05-12 03:10:15 +0800

zhujy gravatar image zhujy
6

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?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-05-12 08:21:28 +0800

robertpic71 gravatar image robertpic71
1275 1

>> 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

link publish delete flag offensive edit

answered 2009-05-12 08:40:37 +0800

robertpic71 gravatar image robertpic71
1275 1

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

link publish delete flag offensive edit

answered 2009-05-14 05:44:51 +0800

zhujy gravatar image zhujy
6

robertpic71

Thank you very much !
I've seen ZK API carefully, as you told me, and arg0 is definitely what I want, thanks again

link publish delete flag offensive edit
Your reply
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]

Question tools

Follow

RSS

Stats

Asked: 2009-05-12 03:10:15 +0800

Seen: 721 times

Last updated: Dec 20 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More