-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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
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
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.
Asked: 2011-07-17 07:58:52 +0800
Seen: 311 times
Last updated: Aug 03 '11