ZK8 Features for MVC - Shadow Elements - Part 1"
Robertwenzel (talk | contribs) |
Robertwenzel (talk | contribs) |
||
Line 27: | Line 27: | ||
* '''<if>''' | * '''<if>''' | ||
− | : | + | : most useful when used with dynamic @load expressions in MVVM |
− | : | + | : in MVC you can attach/detach components directly (so this is nothing new for MVC) |
+ | : used statically you can render parts of your UI based on a conditional EL expression <code><if test="${some.condition}">...</if></code> | ||
* '''<choose>, <when>, <otherwise>''' | * '''<choose>, <when>, <otherwise>''' | ||
: similar to <if> no real benefit for MVC | : similar to <if> no real benefit for MVC | ||
Line 34: | Line 35: | ||
: very useful see paragraph below | : very useful see paragraph below | ||
* '''<apply>''' | * '''<apply>''' | ||
− | : helps to compose the UI from fragments (more efficiently than <include>) | + | : helps to compose the UI from ZUL fragments (more efficiently than <include>) |
+ | : in java you could just call Executions.createComponents(...) '''LINK ME''' | ||
== Apply == | == Apply == | ||
+ | For static UI composition an <include> | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <include src="customerDetails.zul" customerId="123"/> | ||
+ | </source> | ||
+ | |||
+ | can be replaced by an <apply> element. | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <apply templateURI="customerDetails.zul" customerId="123"/> | ||
+ | </source> | ||
+ | |||
+ | The difference is that an <include> does several things at once. | ||
Revision as of 05:01, 23 August 2016
Robert Wenzel, Engineer, Potix Corporation
August 2016
ZK 8.0
Introduction
ZK 8 added several new Features mainly improving Component control when using the MVVM design pattern. The question I sometimes heard since was: (How )can we benefit from these features in our MVC application ?
To answer the question I'll start with the most prominent features which are:
- shadow elements
- form proxies
Let's have a look where they can be used in the MVC world.
If you are missing a feature let us know in the comments section below.
Shadow Elements in MVC
Some of the Shadow Elements LINK ME are more/less beneficial in MVC than others here a short summary
- <if>
- most useful when used with dynamic @load expressions in MVVM
- in MVC you can attach/detach components directly (so this is nothing new for MVC)
- used statically you can render parts of your UI based on a conditional EL expression
<if test="${some.condition}">...</if>
- <choose>, <when>, <otherwise>
- similar to <if> no real benefit for MVC
- <forEach>
- very useful see paragraph below
- <apply>
- helps to compose the UI from ZUL fragments (more efficiently than <include>)
- in java you could just call Executions.createComponents(...) LINK ME
Apply
For static UI composition an <include>
<include src="customerDetails.zul" customerId="123"/>
can be replaced by an <apply> element.
<apply templateURI="customerDetails.zul" customerId="123"/>
The difference is that an <include> does several things at once.
ForEach
https://www.zkoss.org/wiki/ZK_Developer's_Reference/MVC/Controller/Wire_Components#Shadow_Selectors
CollectionTemplate
ZUL Template
Java Based Template
Using ZK8 Form Proxies in MVC
Creating a Simple CRUD Template
Summary
Download
- The source code for this article can be found on github.
Running the Example
Clone the repository
git clone [email protected]:zkoss-demo/mvc-shadow.git cd mvc-shadow git checkout master
The example war file can be built with maven:
mvn clean package
Execute using jetty:
mvn jetty:run
Then access the overview page http://localhost:8080/mvc-shadow/
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |