-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Consider there are only two UI components in a ZK's MVVM based application
Negative scenarios when an user interacts with this application
Have seen people using forward attribute to achieve this. But, I am not clear. Please let me know if you know how to handle this.
In order to 'link' a command with a constrained property you can use a conditional save binding.
<textbox value="@load(vm.idNumber) @save(vm.idNumber, before='submit')"
constraint="..."/>
<button label="submit" onClick="@command('submit')"/>
Now the submit command will ensure the save binding above succeeds before executing the command. In case of an invalid value in the textbox the call to getValue with result in a WrongValueException -> failing the @save binding -> not executing the 'submit' command.
Here a runnable example: https://zkfiddle.org/sample/ujl6bu/1-conditional-save-binding-to-prevent-command
Here the diagram, in this case the safe-before phase will fail, preventing the command execution. https://books.zkoss.org/zk-mvvm-book/9.5/databinding/commandbinding.html#phases-of-command-execution
You might also consider using a binding @validator instead of a component contraint, to have more explicit control from your viewmodel.
Asked: 2021-07-29 02:12:08 +0800
Seen: 9 times
Last updated: Aug 02 '21
ZK 7.0.0 and Liferay 6.2.0 GA @Command Problem
Which one is good for better performance ?
How to Disable Mandatory Constraint for email textbox
Zk Textbox constraint fire only once
MVVM, How to display @validator error like the constraint attribut error ?
Selectbox - constraint="no empty" not working
Add dollar Sign ($) to textbox constraint.
MVVM Radio button with form binding
How to handle big (large) file upload?
Below code from jo.js causes "Invalid object calling" error in IE10. Please provide solution.