Test Included ZUL"

From Documentation
(Created page with "{{ZATSEssentialsPageHeader}} Since 1.1.0 ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component<ref>For more details, please refer to [[ZK_Developer%27s_Reference/...")
 
(10 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
  Since 1.1.0
 
  Since 1.1.0
  
 
+
ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Include]] and [[ZK_Component_Reference/Essential_Components/Include]]</ref> and <javadoc method="createComponents(String, Component, Map)">org.zkoss.zk.ui.Execution</javadoc> method<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Load_ZUML_in_Java]]</ref> to include and/or reuse ZUL pages or others such as servlet or JSP.  
ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Include]] and [[ZK_Component_Reference/Essential_Components/Include]]</ref> and <javadoc method="createComponents(String, Component, Map)">org.zkoss.zk.ui.Execution</javadoc> method<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Load_ZUML_in_Java]]</ref> to include and reuse ZUL pages or others. In ZATS Mimic, we can test ZUL pages which are included by outer pages directly; just connect to such ZUL pages through the <tt>Client.connect(String)</tt> method as usual.  
+
In ZATS Mimic, we can test ZUL pages which are included by outer pages directly; simply use the <tt>Client.connect(String)</tt> method to connect to the ZUL page (like how you would normally do) you want to test.  
  
 
= Test Included ZUL Pages with Arguments =
 
= Test Included ZUL Pages with Arguments =
Sometimes, we pass some arguments to included ZUL pages for flexibility, and the arguments can be retrieved from the implicit objects [[ZUML_Reference/EL_Expressions/Implicit_Objects/arg|arg]] in such ZUL pages. ZATS Mimic introduces another connecting method <tt>Client.connectAsIncluded(String, Map<String, Object>)</tt> for above case. Following is a typical example of connecting to a included ZUL page with specific arguments:
+
Sometimes, however, we pass some arguments, which can be retrieved from implicit objects [[ZUML_Reference/EL_Expressions/Implicit_Objects/arg|arg]] to included ZUL pages for flexibility. ZATS Mimic therefore introduces a new connecting method <tt>Client.connectAsIncluded(String, Map<String, Object>)</tt> with the ability to connect to an included a ZUL page with specific arguments.  Following is a typical example:
  
 
'''included.zul'''
 
'''included.zul'''
 
<source lang="xml" high="2">
 
<source lang="xml" high="2">
 
<zk>
 
<zk>
<label id="msg" value="${arg.message }" />
+
<label id="msg" value="${arg.message}" />
 
</zk>
 
</zk>
 
</source>
 
</source>
* '''Line 2''': The value is retrieved from arguments.
+
* '''Line 2''': Value is retrieved from arguments.
  
  

Revision as of 04:48, 23 April 2013


Since 1.1.0

ZK provides the Include component[1] and Execution.createComponents(String, Component, Map) method[2] to include and/or reuse ZUL pages or others such as servlet or JSP. In ZATS Mimic, we can test ZUL pages which are included by outer pages directly; simply use the Client.connect(String) method to connect to the ZUL page (like how you would normally do) you want to test.

Test Included ZUL Pages with Arguments

Sometimes, however, we pass some arguments, which can be retrieved from implicit objects arg to included ZUL pages for flexibility. ZATS Mimic therefore introduces a new connecting method Client.connectAsIncluded(String, Map<String, Object>) with the ability to connect to an included a ZUL page with specific arguments. Following is a typical example:

included.zul

<zk>
	<label id="msg" value="${arg.message}" />
</zk>
  • Line 2: Value is retrieved from arguments.


Test.java

@Test
public void test() {
	Map<String, Object> args = new HashMap<String, Object>();
	args.put("message", "Hello world!");
	Client client = Zats.newClient();
	DesktopAgent desktop = client.connectAsIncluded("/included.zul", args);
	Label msg = desktop.query("#msg").as(Label.class);
	Assert.assertEquals("Hello world!", msg.getValue());
}
  • Line 12-13: Prepare arguments for included ZUL page.
  • Line 15: Connect to included ZUL page with arguments.


Notes




Last Update : 2013/04/23

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