From Documentation

Jump to: navigation, search


Communicating among pages in the same desktop is straightforward. First, you can use attributes to share data. Second, you can use event to notify each other.

Identify a Page

To communicate among pages, we have to assign an identifier to the target page. In ZUML, it is done by the use of the page directive:

<?page id=" foo"?>
<window id="main"/>

Then we could retrieve it by use of Desktop.getPage(String) or by use of a utility class called Path. For example, the following statements could access the main window above:


As shown, Path.getComponent(String) considers an ID starting with double slashes as a page's ID.

Use Attributes

Each component, page, desktop, session and Web application has an independent map of attributes. It is a good place to share data among components, pages, desktops and even sessions.

In Java , you could use "setAttribute()","removeAttribute()" and "getAttribute()" of Component, Page and so on to share data. Another way is using the scope argument to identify which scope you want to access. (In the following example, assuming comp is a component.)

 comp.getAttribute("some", comp.DESKTOP_SCOPE);
 comp.getDesktop().getAttribute("some"); //is equivalent to previous line

In zscript and EL expressions, you could use the implicit objects: componentScope, pageScope, desktopScope, sessionScope, requestScope and applicationScope.


Post and Send Events

You could communicate among pages in the same desktop. The way to communicate is to use the Events.postEvent(Event) or Events.sendEvent(Event) to notify a component in the target page.

For example,

 Events.postEvent(new Event("SomethingHappens",

You can also pass the data with the event object. The third parameter in Events.postEvent(Event) will be put into Event.getData(). You could the data you want with it.

Events.postEvent("onTest", target, "this will be send");

Version History

Last Update : 2011/7/25

Version Date Content

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.

You got stuck here?
Let us know how we can improve this page
For specific questions please use the forum