Load ZUML in Java"

From Documentation
Line 3: Line 3:
 
__TOC__
 
__TOC__
  
<javadoc>org.zkoss.zk.ui.Execution</javadoc> provides a collection of methods to allow you to create components based a ZUML document, such as <javadoc method="createComponents(java.lang.String, org.zkoss.zk.ui.Component, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc>, <javadoc method="createComponentsDirectly(java.lang.String, java.lang.String, org.zkoss.zk.ui.Component, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc> and many others. For example,
+
<javadoc>org.zkoss.zk.ui.Execution</javadoc> provides a collection of methods to allow you to create components based a ZUML document, such as <javadoc method="createComponents(java.lang.String, org.zkoss.zk.ui.Component, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc>, <javadoc method="createComponentsDirectly(java.lang.String, java.lang.String, org.zkoss.zk.ui.Component, java.util.Map)">org.zkoss.zk.ui.Execution</javadoc> and many others.
 +
In additions, <javadoc>org.zkoss.zk.ui.Executions</javadoc> provides a similar collection of shortcuts, so that you don't have to retrieve the current execution first.
 +
 
 +
For example,
  
 
<source lang="Java">
 
<source lang="Java">
Line 9: Line 12:
 
     private Window main; //assumed wired automatically
 
     private Window main; //assumed wired automatically
 
     public void onClick() {
 
     public void onClick() {
         Executions.getCurrent().createComponentsDirectly("<listbox><listitem label=\"foo\"/></listbox>", "zul", this, null);
+
         Executions.createComponentsDirectly(
 +
          "<listbox><listitem label=\"foo\"/></listbox>", "zul", this, null);
 
     }
 
     }
 
...
 
...
 
</source>
 
</source>
 +
 +
=Create Components 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.
 +
 +
<source lang="Java">
 +
Map arg = new HashMap();
 +
arg.put("some.param", someValue);
 +
Executions.createComponents("/foo/my.zul", parent, arg);
 +
</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.
  
 
=Version History=
 
=Version History=

Revision as of 07:31, 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 Components 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);

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.

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.