-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am trying the framework, and I want to know what is good practice for what I would do.
I have a jsp in which I would have three parts: a header, a main and a footer.
My header is another jsp, footer will be a zul as the main.
For this, I did include.
1. For each zul, should I declare a window element? or can I do something such as:
<zk>
<div>
......
</ div>
</ zk>
2. Depending on the previous response, where should i declare the "appy" attribute to link a controller to my zul (knowing that I would use a GenericForwardComposer for a context-oriented MVC if possible).
Thank you.
Hi Mychal,
1.
Yes you can.
2.
try <div apply="..."> ...
hhhmmm imagine a zul footer of this style:
<zk> <div id="footer"> <image id="flagEN" tooltip="en"/> <image id="flagDE" tooltip="de"/> </ div> <popup id="en"/> <popup id="de"/> </ zk>
If I put an apply on the div, is that it will work for any page zul? can i access to element popup?
Thanks
Yes you can,
a MVC sample below
package j2ld3ad9$v1;import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Include;
import org.zkoss.zul.Label;
import org.zkoss.zul.Popup;public class FooterComposer extends GenericForwardComposer {
Button footer_btn;
Label footer_lb;public void onClick$footer_btn() {
((Popup)page.getFellow("footer").getFellow("footer_popup")).open(footer_btn, "end_before");
Include mainInclude = (Include)page.getFellow("main");
if (mainInclude.hasFellow("main_one_popup"))
((Popup)mainInclude.getFellow("main_one_popup")).open(mainInclude, "end_before");
else
((Popup)mainInclude.getFellow("main_two_popup")).open(mainInclude, "end_before");
}
}
<zk>
<div id="divFooter" apply="j2ld3ad9$v1.FooterComposer">
<button id="footer_btn" label="show all popup" />
<label id="footer_lb" value="footer_lb" />
</div>
<popup id="footer_popup">
<label value="footer popup is opened" />
</popup>
</zk>
package j2ld3ad9$v1;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Include;
import org.zkoss.zul.Label;public class MainTwoComposer extends GenericForwardComposer {
Button main_two_btn;public void doAfterCompose (Component comp) throws Exception {
super.doAfterCompose(comp);
if (page.hasFellow("footer"))
((Label)page.getFellow("footer").getFellow("divFooter").getFellow("footer_lb")).setValue("currently at main_one");
}public void onClick$main_two_btn () {
((Include)page.getFellow("main")).setSrc("main_one.zul");
}
}
<zk>
<div id="divMainTwo" apply="j2ld3ad9$v1.MainTwoComposer">
<button id="main_two_btn" label="change to main one" />
</div>
<popup id="main_two_popup">
<label value="main two popup is opened" />
</popup>
</zk>
package j2ld3ad9$v1;import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Include;
import org.zkoss.zul.Label;public class MainOneComposer extends GenericForwardComposer {
Button main_one_btn;public void doAfterCompose (Component comp) throws Exception {
super.doAfterCompose(comp);
if (page.hasFellow("footer"))
((Label)page.getFellow("footer").getFellow("divFooter").getFellow("footer_lb")).setValue("currently at main_two");
}public void onClick$main_one_btn () {
((Include)page.getFellow("main")).setSrc("main_two.zul");
}
}
<zk>
<div id="divMainOne" apply="j2ld3ad9$v1.MainOneComposer">
<button id="main_one_btn" label="change to main two" />
</div>
<popup id="main_one_popup">
<label value="main one popup is opened" />
</popup>
</zk>
<zk>
<include id="main" src="main_one.zul" width="300px" height="300px" />
<include id="footer" src="footer.zul" width="300px" height="100px" />
</zk>
For more information, please refer to
Getting Started
Component-based UI
ZK MVC Made Easy
Asked: 2011-10-21 09:30:16 +0800
Seen: 452 times
Last updated: Nov 01 '11