-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am saving multiple row at same time. I applied constrain on filed but it is not working while I am submitting form.
I followed below example for test
1) blog.zkoss.org/2015/02/03/zk8-new-form-binding-approach 2) github.com/zkoss-demo/zk8-formbinding-demo
But for Category list I set constraint for Category but it is not working.
Can anyone please help me, I stuck with this issue since week?
Thanks, Hitesh
Hi Jeanca,
Please find below code I am developed based on above example constraint is not working at severity. Can you please help if you know what is problem.
1) Problem POJO
public class Problem{
private String name;
private String desc;
private String isAvailable;
//other property
private List<Deficiency> deficiencies = new ArrayList<Deficiency>();
//getter setter
}
2) Deficiency POJO
public class Deficiency{
private String severity;
//other property
//gettr setter
}
3) method to dynamically add Deficiency
@Command public void addDefeciency(@BindingParam("problem") Problem problem) {
Deficiency deficiency = new Deficiency();
List<Deficiency> deficiencies = problem.getDeficiencies();
deficiencies.add(deficiency);
}
4) to display on UI <groupbox form="@id('fx') @load(vm.currentProblem) @save(vm.currentProblem, before={'save'})" hflex="true" mold="3d"> <label style="font-weight:bold; color:#215891;" value="Test: "/> <groupbox> <grid hflex="true"> <columns> <column width="140px"/> <column/> <column width="120px"/> <column/> </columns> <rows>
<row>
<label value="Available?" />
<hlayout>
<combobox
constraint="no empty:please select" readonly="true"
selectedItem="@bind(fx.isAvailable)">
<comboitem label="Y"
value="1" />
<comboitem label="N"
value="0" />
</combobox>
</hlayout>
</row>
</rows>
</grid>
</groupbox>
<groupbox>
<caption label="Defeciency" />
<grid model="@bind(fx.deficiencies)">
<columns>
<column width="100%" />
<column />
</columns>
<template name="model">
<row>
<grid>
<columns>
<column width="140px" />
<column />
<column width="120px" />
<column />
</columns>
<rows>
<row hflex="3">
<label value="Severity" />
<combobox
constraint="no empty:please select"
readonly="true"
selectedItem="@bind(each.severity)">
<comboitem label="Y"
value="1" />
<comboitem label="N"
value="0" />
</combobox>
</row>
</rows>
</grid>
</row>
</template>
</grid>
<button onClick="@command('addDefeciency',problem=fx)" label="Add Defeciency"/>
</groupbox>
<groupbox>
<button label="Save"
onClick="@command('save')">
</button>
</groupbox>
</groupbox>
Asked: 2016-07-08 22:16:03 +0800
Seen: 33 times
Last updated: Jul 18 '16
unwanted logging of custom WrongValueException
How to Disable Mandatory Constraint for email textbox
Java Script error zk.wpd in Explorer
wrong valueException come in front of modal popup [closed]
textbox constraint="no empty", how to cancel ? [closed]
[solved]textbox constraint="no empty", how to cancel it?
Zk Textbox constraint fire only once
Validate datebox invalid input with validators
MVVM, How to display @validator error like the constraint attribut error ?