ZATS ConnectAsIncluded"

From Documentation
Line 3: Line 3:
  
  
ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component allows us to include and reuse ZUL pages or others.<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Include]] and [[ZK_Component_Reference/Essential_Components/Include]]</ref> 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.
+
ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component allows us to include and reuse ZUL pages or others.<ref>For more details, please refer to [[ZK_Developer%27s_Reference/UI_Composing/ZUML/Include]] and [[ZK_Component_Reference/Essential_Components/Include]]</ref> 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.  
  
 
= Test Included ZUL Pages with Specific Arguments =
 
= Test Included ZUL Pages with Specific Arguments =
Sometimes, we pass some arguments to included ZUL pages for flexibility purpose, 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, we pass some arguments to included ZUL pages for flexibility purpose, 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. Besides, this connecting method can be applied to test ZUL pages included by <javadoc method="createComponents(String, Component, Map)">org.zkoss.zk.ui.Execution</javadoc> method.
 +
Following is a typical example of connecting to a included ZUL page with specific arguments:
  
 
'''included.zul'''
 
'''included.zul'''
Line 35: Line 36:
 
'''Notes'''
 
'''Notes'''
 
<references/>
 
<references/>
 
 
== Test Included ZUL Pages with Defer Mode ==
 
There is no different between testing a normal ZUL page or testing a included ZUL page with defer mode. We can just use the normal <tt>Client.connect(String)</tt> method to connect it.
 
  
  
 
{{ZATSEssentialsPageHeader}}
 
{{ZATSEssentialsPageHeader}}
 
{{ZATSEssentialsPageFooter}}
 
{{ZATSEssentialsPageFooter}}

Revision as of 02:54, 6 July 2012

aowang



Since 1.1.0


ZK provides the Include component allows us to include and reuse ZUL pages or others.[1] In ZATS Mimic, we can test ZUL pages which are included by outer pages directly; just connect to such ZUL pages through the Client.connect(String) method as usual.

Test Included ZUL Pages with Specific Arguments

Sometimes, we pass some arguments to included ZUL pages for flexibility purpose, and the arguments can be retrieved from the implicit objects arg in such ZUL pages. ZATS Mimic introduces another connecting method Client.connectAsIncluded(String, Map<String, Object>) for above case. Besides, this connecting method can be applied to test ZUL pages included by Execution.createComponents(String, Component, Map) method. Following is a typical example of connecting to a included ZUL page with specific arguments:

included.zul

<zk>
	<label id="msg" value="${arg.message }" />
</zk>
  • Line 2: The 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


aowang




Last Update : 2012/07/06

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