Load ZUML in Java"

From Documentation
Line 18: Line 18:
 
</source>
 
</source>
  
=Create Components from an URI=
+
=Create from an URI=
  
 
There are several ways to create components based a ZUML document. One of the most common approach is to create components from a URI.
 
There are several ways to create components based a ZUML document. One of the most common approach is to create components from a URI.
Line 25: Line 25:
 
Map arg = new HashMap();
 
Map arg = new HashMap();
 
arg.put("some.param", someValue);
 
arg.put("some.param", someValue);
Executions.createComponents("/foo/my.zul", parent, arg);
+
Executions.createComponents("/foo/my.zul", parent, arg); //attach to page no matter parent is null or not
 
</source>
 
</source>
  
where <code>parent</code> (an instance of <javadoc>org.zkoss.zk.ui.Component</javadoc>) will become the parent of the components specified in the ZUML document. If <code>parent</code> is null, the components specified in the ZUML documents will become the root components of the current page.
+
where <code>parent</code> (an instance of <javadoc>org.zkoss.zk.ui.Component</javadoc>) will become the parent of the components specified in the ZUML document. If <code>parent</code> is null, the components specified in the ZUML documents will become the root components of the current page. In other words, the components created by <javadoc method="createComponents(java.lang.String, org.zkoss.zk.ui.Component, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc> will be attached the current page.
 +
 
 +
If you want to create components that won't be attached to a page, you could use <javadoc method="createComponents(java.lang.String, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc>. It is useful if you wan to maintain a cache of components or implement a utility. For example,
 +
 
 +
<source lang="Java">
 +
Map arg = new HashMap();
 +
arg.put("some.param", someValue);
 +
Component[] comps = Executions.createComponents("/foo/my.zul", arg); //won't be attached to a page
 +
</source>
 +
 
 +
=Create from PageDefintion=
 +
 
 +
=Create from Content Directly=
  
 
=Version History=
 
=Version History=

Revision as of 07:44, 9 November 2010



Execution provides a collection of methods to allow you to create components based a ZUML document, such as Execution.createComponents(String, Component, Map), Execution.createComponentsDirectly(String, String, Component, Map) and many others. In additions, Executions provides a similar collection of shortcuts, so that you don't have to retrieve the current execution first.

For example,

public class Controller extends GenericForwardComposer {
    private Window main; //assumed wired automatically
    public void onClick() {
        Executions.createComponentsDirectly(
           "<listbox><listitem label=\"foo\"/></listbox>", "zul", this, null);
    }
...

Create from an URI

There are several ways to create components based a ZUML document. One of the most common approach is to create components from a URI.

Map arg = new HashMap();
arg.put("some.param", someValue);
Executions.createComponents("/foo/my.zul", parent, arg); //attach to page no matter parent is null or not

where parent (an instance of Component) will become the parent of the components specified in the ZUML document. If parent is null, the components specified in the ZUML documents will become the root components of the current page. In other words, the components created by Execution.createComponents(String, Component, Map) will be attached the current page.

If you want to create components that won't be attached to a page, you could use Execution.createComponents(String, Map). It is useful if you wan to maintain a cache of components or implement a utility. For example,

Map arg = new HashMap();
arg.put("some.param", someValue);
Component[] comps = Executions.createComponents("/foo/my.zul", arg); //won't be attached to a page

Create from PageDefintion

Create from Content Directly

Version History

Last Update : 2010/11/9

Version Date Content
     



Last Update : 2010/11/09

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