ZATS ConnectAsIncluded"
Line 2: | Line 2: | ||
__TOC__ | __TOC__ | ||
Since 1.1.0 | Since 1.1.0 | ||
+ | |||
+ | |||
+ | ZK provides the <javadoc>org.zkoss.zul.Include</javadoc> component allows us to include or reuse ZUL page 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> We can directly test a ZUL page which is included by outer pages; just connect to such ZUL through the <tt>Client.connect(String)</tt> method as usual. | ||
= Connect as Included = | = Connect as Included = | ||
+ | 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]] inside of 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 included ZUL page with arguments: | ||
+ | |||
+ | '''included.zul''' | ||
+ | <source lang="xml" high="2"> | ||
+ | <zk> | ||
+ | <label id="msg" value="${arg.message }" /> | ||
+ | </zk> | ||
+ | </source> | ||
+ | * '''Line 2''': The value is retrieved from arguments. | ||
− | + | ||
− | + | '''Test.java''' | |
+ | <source lang="java" start="10" high="12, 13, 14"> | ||
+ | @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("/~./basic/included.zul", args); | ||
+ | Label msg = desktop.query("#msg").as(Label.class); | ||
+ | Assert.assertEquals("Hello world!", msg.getValue()); | ||
+ | } | ||
+ | </source> | ||
+ | * '''Line 12-13''': | ||
+ | * '''Line 14''': | ||
Revision as of 04:37, 5 July 2012
Since 1.1.0
ZK provides the Include component allows us to include or reuse ZUL page or others.[1] We can directly test a ZUL page which is included by outer pages; just connect to such ZUL through the Client.connect(String) method as usual.
Connect as Included
Sometimes, we pass some arguments to included ZUL pages for flexibility purpose, and the arguments can be retrieved from the implicit objects arg inside of ZUL pages. ZATS Mimic introduces another connecting method Client.connectAsIncluded(String, Map<String, Object>) for above case. Following is a typical example of included ZUL page with 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("/~./basic/included.zul", args);
Label msg = desktop.query("#msg").as(Label.class);
Assert.assertEquals("Hello world!", msg.getValue());
}
- Line 12-13:
- Line 14:
Notes
- ↑ For more details, please refer to ZK_Developer's_Reference/UI_Composing/ZUML/Include and ZK_Component_Reference/Essential_Components/Include
Including with Defer Mode
There is no different between testing a normal ZUL or testing a included ZUL directly. We can just use the normal Client.connect(String url) method to connect ZUL.