0

default value for the property apply

asked 2011-07-17 07:58:52 +0800

sandalo gravatar image sandalo
25 3

updated 2011-07-17 07:59:40 +0800

I am new to ZK forum and I have many doubts.
I am a composer specializing class that does almost all the work. So ask. How to set default composer for my windows? In other words, how to set a default value for the property apply for my windows?

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-07-17 08:52:13 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

updated 2011-07-17 10:28:50 +0800

Hi Sandalo,

you may refer to
ZK MVC
Implementing_ZK_MVC

or do you mean "apply a composer to each page"?
it can be done with System-level Composer

link publish delete flag offensive edit

answered 2011-07-18 08:17:16 +0800

sandalo gravatar image sandalo
25 3

Benbai Thanks for your reply.
My scenario is as follows: I am using the MVC pattern in my APP. All my Windows are using a class AppCtr or a sub-class of AppCtr. However, when the Window is used AppCtr and not one of its sub-classes would not need to set the attribute apply, in other words, if I do not set the attribute "apply", the default is AppCtr.

Thanks

link publish delete flag offensive edit

answered 2011-07-18 22:45:39 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

Hi Sandalo,
let's say, there are two composer called TestComposer and TestComposerTwo,
and we want apply TestComposer to all windows not applied the TestComposerTwo,

there are several things to do:

1.
make sure Window is the root component of a page,
system-level composer will only apply to root components.

for example, if there are buttonOne and buttonTwo in composer and the zul is as follows:

<zk>
	<window>
		<window>
			<button id="buttonTwo" label="buttonTwo zero in test" />
		</window>
	</window>
	<window>
		<button id="buttonOne" label="buttonOne in test" />
	</window>
</zk>

then the buttonOne will be wired but buttonTwo will not.

2.
In TestComposer, check whether the window is applied other composer,
if it is true then just return, as follows:

public void doAfterCompose(Component comp) throws Exception {
	Iterator it = ((Window)comp).getAttributes().keySet().iterator();
	while (it.hasNext()) {
		// add more check if more other composers
		if ("$TestComposerTwo".equals(it.next().toString()))
			return;
	}
	super.doAfterCompose(comp);
}

3.
regist TestComposer as system-level composer in /WEB-INF/zk.xml

<listener>
	<listener-class>test.TestComposer</listener-class>
</listener>

it should work now.

link publish delete flag offensive edit

answered 2011-08-03 17:11:38 +0800

sandalo gravatar image sandalo
25 3

Ok. benbai. Tank you.

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: 2011-07-17 07:58:52 +0800

Seen: 311 times

Last updated: Aug 03 '11

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