New Features of ZK 6.0.1"

From Documentation
m
Line 5: Line 5:
 
}}
 
}}
  
 +
=Reference Binding=
  
 +
{{ZK PE and EE}}
 +
 +
Reference binding allows us to reference an EL expression with a customized name. We can use this reference in another EL expression nested in the component that is binded to this reference. Typically, we use reference binding to shorten expressions or to modularize the view<ref>When using this feature, you have to avoid saving to a first-term only expression, read [http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM/Data_Binding/Property_Binding#Limitation here] for more detail.</ref>.
 +
 +
Steps to use this feature:
 +
# Bind a custom attribute on a component with <tt> @ref </tt>.
 +
# Use the custom attribute in other EL expressions that are nested in children components
 +
 +
<source lang="xml" high="3,5,8">
 +
 +
<window apply="org.zkoss.bind.BindComposer"
 +
viewModel="@id('vm') @init('foo.MyVM')">
 +
<vlayout p="@ref(vm.person)">
 +
<hlayout>
 +
First Name: <textbox value="@bind(p.firstName)" />
 +
</hlayout>
 +
<hlayout>
 +
Last Name: <textbox value="@bind(p.lastName)" />
 +
</hlayout>
 +
</vlayout>
 +
</window>
 +
 +
</source>
 +
 +
As shown in the example above, we add a reference <tt>@ref</tt> to '''vm.person''' with a name '''p''' to <i>vlayout</i>. This way, '''p'''  inside the <i>vlayout</i> can be used by other EL expressions.
  
 
=Download & other resources=
 
=Download & other resources=

Revision as of 04:38, 27 April 2012

DocumentationSmall Talks2012MayNew Features of ZK 6.0.1
New Features of ZK 6.0.1

Author
Timothy Clare, Potix Corporation
Date
April 2, 2012
Version
ZK 6.0.1

Reference Binding

  • Available for ZK:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion pe-ee.png

Reference binding allows us to reference an EL expression with a customized name. We can use this reference in another EL expression nested in the component that is binded to this reference. Typically, we use reference binding to shorten expressions or to modularize the view[1].

Steps to use this feature:

  1. Bind a custom attribute on a component with @ref .
  2. Use the custom attribute in other EL expressions that are nested in children components
<window apply="org.zkoss.bind.BindComposer" 
	viewModel="@id('vm') @init('foo.MyVM')">
	<vlayout p="@ref(vm.person)">
		<hlayout>
			First Name: <textbox value="@bind(p.firstName)" />
		</hlayout>
		<hlayout>
			Last Name: <textbox value="@bind(p.lastName)" />
		</hlayout>
	</vlayout>
</window>

As shown in the example above, we add a reference @ref to vm.person with a name p to vlayout. This way, p inside the vlayout can be used by other EL expressions.

Download & other resources


Comments



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


  1. When using this feature, you have to avoid saving to a first-term only expression, read here for more detail.