0

jsp -> n zul / the good way to do ?

asked 2011-10-21 09:30:16 +0800

Mychal gravatar image Mychal
151 3

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.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2011-10-23 10:45:07 +0800

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

Hi Mychal,

1.
Yes you can.

2.
try <div apply="..."> ...

link publish delete flag offensive edit

answered 2011-10-25 09:10:03 +0800

Mychal gravatar image Mychal
151 3

Thank you.

I will try all of this :)

link publish delete flag offensive edit

answered 2011-10-31 16:32:08 +0800

Mychal gravatar image Mychal
151 3

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

link publish delete flag offensive edit

answered 2011-11-01 12:04:51 +0800

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

Yes you can,
a MVC sample below

ZKFiddle-Link

FooterComposer.java
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");
}
}


footer.zul
<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>

MainTwoComposer.java
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");
}
}


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

MainOneComposer.java
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");
}
}


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

index.zul
<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

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-10-21 09:30:16 +0800

Seen: 452 times

Last updated: Nov 01 '11

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