Reputation: 1197
I'm new in zk ,I have a form with field and I defined some constraint on those fields and a submit button ,who can I link the submit button with the form and fields ,so I want click on the button the fields where the constraint not satisfied will appear in red ,Now my button doesn't see if the constraint are satisfied ,I know that I could verify in java code but that will not make the fields.
Upvotes: 0
Views: 2336
Reputation: 4277
Here is a nice example on zk fiddle of how you do it in MVVM.
You need to work with @load
and @save
seperated so you can tell to save before the command.
When your constraint fails the @command
is never fired.
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('pkg$.VM')">
<hbox>
<textbox value="@load(vm.name) @save(vm.name,before='register')" constraint="no empty" />
<label value="@load(vm.name)" />
</hbox>
<hbox>
<button label="register" onClick="@command('register')" />
</hbox>
</window>
Edit : For MVC
You'll find in the zk documentation a very nice description with example of how to make constraints in mvc.
Upvotes: 0
Reputation: 1197
With MVC you could check componant if there are all validate before submitting here a good code it's helpful and good luck
Upvotes: 0