0

how to refer to paren include from child page

asked 2006-04-15 13:09:57 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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.



delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2006-04-16 08:28:02 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

link publish delete flag offensive edit

answered 2006-04-16 08:45:14 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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


link publish delete flag offensive edit

answered 2006-04-16 15:27:11 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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?


link publish delete flag offensive edit

answered 2006-04-16 15:38:09 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


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

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: 2006-04-15 13:09:57 +0800

Seen: 652 times

Last updated: Apr 16 '06

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