-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3688170
By: dzasypkin
Hi,
Is there any way to refer to the parent <include> component from its child page?
I have two zul files - a root page which contains <include> element, and its child page. Is it possible to obtain a reference to elements of the root page from the Java code residing in the child page file (without using desktop attributes)? Something like page.getParent()..
Thank you.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3688854
By: henrichen
The included page is actually under the same Desktop as the root page. From a desktop's point of view, they are all the same pages. That is, you can use
getDesktop().getPage("myroot") to get your root page. Here I assume your root page id is "myroot". And since you get the root page, you can get whatever elements you want, <include> component is no different.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3688864
By: henrichen
If you want to decouple the root page id from the included page code, you can pass that information as a request parameter into it. Then use
Path.getComponent(passedPath) to get that <include> component at the root page.
/henri
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3689087
By: dzasypkin
Henri,
Thanks for the answer.
I was able to set up the following "proof-of-concept" generic example.
Root zul:
----------------------------
<window id="main">
<include id="inc"/>
<zscript>
inc.src="test2.zul?parentPath=//" + page.id + Path.getPath(inc); </zscript> </window>
test2.zul:
----------------------------
<zk>
<zscript>
String path = Executions.getCurrent().getParameter("parentPath");
Component parent = Path.getComponent(path); </zscript> <label value="Parent id: ${parent.id}"/> <separator/> <label value="Parent path: ${param.parentPath}"/> </zk>
But if I remove id="main" attribute assignment from the window element, the above code throws an exception:
com.potix.zk.ui.UiException: com.potix.web.servlet.ServletException: Unable to evaluate an EL expression: ${u:redraw(root, null)}
This exception is caused by Path.getComponent call. Seems like getComponent() cannot evaluate a path string with a window id, which was assigned automatically (not specified in the zul file).
Is this a bug? Or am I missing something?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3689096
By: henrichen
Looks like a bug. Do you have the stack trace? Post it as a bug so we can track it.
/henri
Asked: 2006-04-15 13:09:57 +0800
Seen: 652 times
Last updated: Apr 16 '06