New Features of ZK 6.0.1"
Tmillsclare (talk | contribs) |
Tmillsclare (talk | contribs) |
||
Line 49: | Line 49: | ||
For more information please see the [[ZK_Developer's_Reference/MVVM/Data_Binding/Converter | developer's reference]]. | For more information please see the [[ZK_Developer's_Reference/MVVM/Data_Binding/Converter | developer's reference]]. | ||
+ | |||
+ | == Form Bean Validator == | ||
+ | |||
+ | {{ZK EE}} | ||
+ | Since 6.0.1 | ||
+ | |||
+ | This feature is similar to the Bean Validator, as it integrates JavaBean Validation and validates a bean's all saving properties. For the configuration and JavaBean usage, please refer to [[ZK_Developer's_Reference/MVVM/Data_Binding/Validator#Prepare_to_Use_JSR_303 | Prepare_to_Use_JSR_303]] | ||
+ | |||
+ | =Usage= | ||
+ | |||
+ | Use this validator with the name '''formBeanValidator''' and set a unique prefix key by '''prefix''' argument of validator. When any property of the bean is invalid, it puts the invalid message to validation message holder with key '''prefix'''+propertyName. | ||
+ | |||
+ | <source lang="xml" high="4,6"> | ||
+ | <window id="win" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init(foo.MyViewModel)" | ||
+ | validationMessages="@id('vmsgs')"> | ||
+ | <grid width="600px" form="@id('fx') @load(vm.user) @save(vm.user,after='save') | ||
+ | @validator('formBeanValidator',prefix='p_')"> | ||
+ | <textbox value="@bind(fx.firstName)"/> | ||
+ | <label value="@load(vmsgs['p_firstName'])"/> | ||
+ | </grid> | ||
+ | <!--more components--> | ||
+ | </window> | ||
+ | </source> | ||
+ | |||
+ | For more information please refer to the [[ZK_Developer's_Reference/MVVM/Data_Binding/Validator#Bean_Validator | developer's reference]]. | ||
=Download & other resources= | =Download & other resources= |
Revision as of 08:13, 27 April 2012
Timothy Clare, Potix Corporation
April 2, 2012
ZK 6.0.1
Reference Binding
- Available for ZK:
Reference binding allows us to reference an expression with a customized name. We can use this reference in another EL expression nested in the component that is binded to this reference.
A simple example is as follows:
<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>
Steps to use this feature:
- Bind a custom attribute on a component with @ref .
- Use the custom attribute in other EL expressions that are nested in children components
The above code shows these implemented steps, for more information and more uses please visit the developer's reference.
Children binding now supports a converter
It is now possible to specify a converter when loading children. There is a default converter which attempts to coerce the argument object into a List. The following code provides a sample for this:
<hlayout children="@init(vm.items) @converter(vm.itemConverter)">
<template name="children">
<label value="@load(each) "/>
</template>
</hlayout>
For more information please see the developer's reference.
Form Bean Validator
- Available for ZK:
Since 6.0.1
This feature is similar to the Bean Validator, as it integrates JavaBean Validation and validates a bean's all saving properties. For the configuration and JavaBean usage, please refer to Prepare_to_Use_JSR_303
Usage
Use this validator with the name formBeanValidator and set a unique prefix key by prefix argument of validator. When any property of the bean is invalid, it puts the invalid message to validation message holder with key prefix+propertyName.
<window id="win" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init(foo.MyViewModel)"
validationMessages="@id('vmsgs')">
<grid width="600px" form="@id('fx') @load(vm.user) @save(vm.user,after='save')
@validator('formBeanValidator',prefix='p_')">
<textbox value="@bind(fx.firstName)"/>
<label value="@load(vmsgs['p_firstName'])"/>
</grid>
<!--more components-->
</window>
For more information please refer to the developer's reference.
Download & other resources
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |