-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4561698
By: ayhankibar
Hi,
first of all zul is great. But I have a problem about accesing the object within JSP. Let me explain:
1. The main jsp page (main.jsp) looks like :
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> <%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="z" %>
<z:page>
<z:window id="mainWindowID" border="normal">
<z:div id="issueBaseEditInitiator">
<z:include src="/view/plm/issue/issue/main/edit/zul/EditAffectedParts.zul"/>
</z:div>
<z:div id="issueInformation">
<z:include src="/view/plm/issue/issue/main/edit/zul/IssueInformation.zul"/>
</z:div>
<z:div id="issueUnit">
<z:include src="/view/plm/issue/issue/main/edit/zul/IssueUnit.zul"/>
</z:div>
</z:window>
</z:page>
2. And EditAffectedParts.zul. The code looks like:
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <?init class="com.ps.action.plm.issue.main.edit.zul.IssueBaseEditInitiator" ?>
<window id="issueBaseEditInitiator" title="Affected Part(s)" border="normal"
onCreate="self.onCreate()"
use="com.ps.action.plm.issue.main.edit.zul.IssueBaseEditInitiator"
onClose="self.visible = false; event.stopPropagation();"> <hbox>
<label value="Part #:"/>
...................
...................
...................
</hbox>
</window>
the java code is (IssueBaseEditInitiator.java) :
public class IssueBaseEditInitiator extends Window implements Initiator{
public void onCreate() {
}
public void onOpen(){
}
public void doAfterCompose(Page arg0) throws Exception {
// TODO Auto-generated method stub
}
public void doCatch(Throwable arg0) {
// TODO Auto-generated method stub
}
public void doFinally() {
// TODO Auto-generated method stub
}
public void doInit(Page arg0, Object[] arg1) throws Exception {
}
public List getAffectedParts() {
return new ArrayList();
}
}
3. and IssueInformation.zul looks like EditAffectedParts.zul. It also has the java class named IssueUnitInitiator.java.
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <?init class="com.ps.action.plm.issue.main.edit.zul.IssueUnitInitiator" ?>
<window id="issueUnitInitiator" title="Affected Part(s)" border="normal"
onCreate="self.onCreate()"
use="com.ps.action.plm.issue.main.edit.zul.IssueUnitInitiator"
onClose="self.visible = false; event.stopPropagation();"> </window>
here is my question:
at IssueInformation.zul, or at IssueUnitInitiator.java or at main.jsp I want to able to use/reach the the Window object of EditAffectedParts.zul which ID is issueBaseEditInitiator.
for example at IssueUnitInitiator.java:
public class IssueUnitInitiator extends IssueBaseEditInitiator{
public void onCreate() {
}
public void onOpen(){
}
public void doAfterCompose(Page arg0) throws Exception {
// TODO Auto-generated method stub
}
public void doCatch(Throwable arg0) {
// TODO Auto-generated method stub
}
public void doFinally() {
// TODO Auto-generated method stub
}
public void doInit(Page arg0, Object[] arg1) throws Exception {
}
public void getUnits(String unitName){
HttpServletRequest request =
(HttpServletRequest)Executions.getCurrent().getNativeRequest();
IssueBaseEditInitiator win =
(IssueBaseEditInitiator)request.getAttribute("mainWindow");
List affectedParts = win.getAffectedParts();
}
}
at getUnits function, I want to get the Window object (win) and call the
getAffectedParts() function.
am I doing something wrong, or am I misssing something?
how can I able to do that?
Best regards.
ayhan
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4563245
By: jebberwocky
Dear ayhan
Since the method you want to access is in another "page," did you try this:
IssueBaseEditInitiator win
=(IssueBaseEditInitiator)this.getDesktop().getPage(PAGE_ID).getFellow("issueBase
EditInitiator");
win.getAffectedParts();
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4563291
By: zanyking
The <include> tag will create new Page but still running on the same desktop.
So the best way in your case is set page's id in every your zul pages like
this:
IssueInformation.zul: <?page id="IssueInformation" ?>
EditAffectedParts.zul: <?page id="EditAffectedParts" ?> ...
and then in one of your zul page you can access other page's Components like this :
Collection comps
= Executions.getCurrent().getDesktop().getPage("IssueInformation").getRoots();
for(Component each:comps )
{
each.getFellow()...
}
But in zuljsp, because ZK JspTags's <page> doesn't support setId() method yet, so you better include *.zul then *.jsp.
Although jsp's ZK components still on the same desktop, but the page's ID is auto generated by ZK and you got no way to modify it. We'll fix this problem quickly.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4563378
By: ayhankibar
Hi,
Thank you much. It works perfect.
at EditAffectedParts.zul I use:
<?page id="EditAffectedParts" ?>
and at other zul page's java (initiator) I reach the object like below:
public Window getWindowComponent(String windowName){
Window win = null;
List comps = new
ArrayList(Executions.getCurrent().getDesktop().getPage(windowName).getRoots());
if (comps!=null && comps.size()>0){
for (int i = 0; i < comps.size(); i++) {
Component obj = (Component)comps.get(i);
if (obj instanceof Window){
win = (Window)obj;
break;
}
}
}
return win;
}
public void someFunction(){
IssueBaseEditInitiator win =
(IssueBaseEditInitiator)getWindowComponent("EditAffectedParts");
List list = win.getAffectedParts();
}
Thanks again.
Best regards.
ayhan
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4563414
By: henrichen
You don't have to iterate all root components under a page to find what you want if you have assigned id to the component.
Try
Window win =
(Window) Path.getComponent("//EditAffectedParts/issueBaseEditInitiator");
Read ID space concept in ZK Developer Guide for details.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4563505
By: ayhankibar
Thanks a lot.
it works perfect.
ayhan.
Asked: 2007-10-10 11:47:02 +0800
Seen: 194 times
Last updated: Oct 11 '07