Advanced Usage of Fragment Component

From Documentation
Revision as of 09:03, 12 June 2017 by Rudyhuang (talk | contribs) (Article structure)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WarningTriangle-32x32.png This page is under construction, so we cannot guarantee the accuracy of the content!


DocumentationSmall Talks2017JulyAdvanced Usage of Fragment Component
Advanced Usage of Fragment Component

Author
Rudy Huang, Engineer, Potix Corporation
Date
June 12, 2017
Version
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.