Advanced Usage of Fragment Component
Rudy Huang, Engineer, Potix Corporation
June 12, 2017
ZK 8.5
Introduction
The previous blog post "Client Binding with ZK MVVM for your eyes only" gives you a brief introduction of the Fragment component in upcoming ZK 8.5. This article will extend the introduction and explain advanced usage of this component especially about data validation and event handling.
Data Validation
To ensure data is correct and useful, we can accompany with validators. The fragment component supports property binding validation, form binding validation and client-side property validation available on this component only. This section explains them one by one.
Property Binding and Validation
You can append @validator annotation when you map properties of the view model as properties of a fragment. It helps you to validate data before saving to the view model. If validation fails, the save process will be aborted and the data will stay unchanged.
<fragment viewModel="..."
prop1="@bind(vm.prop1) @validator(vm.validator1)">
// omitted
</fragment>
- Line 2: Append a @validator after @bind annotation to apply a validator.
Self-Defined Message Keys
Form Binding and Validation
JSR 303 Bean Validation
Client-Side Property Validation
The Differences Between @validator and @jsvalidator
Validation Message Holder on Client-Side
Event Handling
Summary
References
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |