-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, how to work with nested objects using form
directive? I need to bind an entire object to form object and validate it with all nested objects. Do nested objects have to be FormProxyObject
too? I'm also using Hibernate.
<div viewModel="@id('vm') @init('com.person.PersonVM')" validationMessages="@id('vmsgs')">
<div class="content" form="@id('fx') @load(vm.person) @save(vm.person,before='save') @validator('vm.FormValidator')">
<label sclass="subtitle is-4" value="Edit Person"/>
<separator />
<div class="field">
<label sclass="label" value="Name" />
<div class="control">
<textbox class="input" value="@bind(fx.name)" />
<label sclass="help is-danger" value="@load(vmsgs['name'])"/>
</div>
</div>
<div class="field">
<label sclass="label" value="Age" />
<div class="control">
<intbox class="input" value="@bind(fx.age)"/>
<label sclass="help is-danger" value="@load(vmsgs['age'])"/>
</div>
</div>
<div class="field">
<label sclass="label" value="Street Name" />
<div class="control">
<textbox class="input" value="@bind(fx.address.streetName)" />
<label sclass="help is-danger" value="@load(vmsgs['streetName'])"/>
</div>
</div>
<div class="field">
<label sclass="label" value="Number" />
<div class="control">
<intbox class="input" value="@bind(fx.address.number)" />
<label sclass="help is-danger" value="@load(vmsgs['number'])"/>
<label sclass="help is-danger" value="@load(vmsgs['numberValid'])"/>
</div>
</div>
<button label="Save" onClick="@command('save')"/>
</div>
</div>
Your code looks correct, the form binding will automatically create a proxy around the nested person.address
object if possible so you can validate the streetName before saving it.
Did you encounter any problem there? Did something not work as expected?
Asked: 2018-10-20 19:43:32 +0800
Seen: 6 times
Last updated: Oct 23 '18
Please help me in form binding
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM