-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579322
By: matteo_barbieri
Hi,
don't know if it's already possible to do something like this...
I have a page where I include two times another page (with its page id).
But if I try to access one of the two included pages I don't know how to call it, because I have 2 pages with the same id.
I wonder if exists something like
<include src='/mypage.zul' pageid='first' /> <include src='/mypage.zul' pageid='second' />
Then I can access the 2 pages with:
Path.getComponent('//first/asdf/');
Path.getComponent('//second/asdf/');
Maybe a feature request?
Thanx
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579333
By: tomyeh
You could access them. But, as we discussed in another thread, components are created by include in the rendering phase. In other words, they are accessible by the includer only after the whole is rendered and sent back to browser. It implies that you could access them only in event listeners, not in the script of the includer.
Of course, the page being included is like any other ZUML page. You could do whatever you want.
We plan to solve this with the macro mechanism. Kill two birds in one stone.
Take a look at the comment in Request 1428252
https://sourceforge.net/tracker/?func=detail&atid=785194&aid=1428252&group_id=15
2762
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579341
By: matteo_barbieri
In fact I want to access them in event listeners.
But how can I select one of the two pages if they have the same id?
I included 2 times but I use them in 2 different ways.
On the logs I have also a warning that tells me that there are 2 pages with the same id.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579362
By: tomyeh
To include the same page twice, you cannot assign page ID to it (so ZK will generate one for you). Then, the question is how to access the component inside the included page without knowing its ID?
One of solutions is to use inter-page communication to exchange data (see also User Guide). The attributes of Desktop is good place.
For example, the includer could set an attribute to prepare the included page to register.
desktop.setAttribute("included", new LinkedList());
Then, the included page could do
((Collection)desktop.getAttribute("included")).add(page);
If you want to use Path, you could add page.getId().
Hope this solves your requirement.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579370
By: tomyeh
After second though, there is another alternative similar to what you suggested:
pass page ID to the included page.
<include src="/mypage.zul?pageid=first"/>
Then, in the included page, you do
<?page id="${param.pageId}"...
This looks much better :)
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579376
By: matteo_barbieri
Sure, much better! :)
Thank you again.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579394
By: tomyeh
Oops, the id attribute of the page doesn't support EL. I'll fix this.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579402
By: matteo_barbieri
I just notice this.
You anticipate me :)
Asked: 2006-02-16 09:12:46 +0800
Seen: 679 times
Last updated: Feb 16 '06