-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have to submit multiple rows at a time.
I have USER POJO and Address POJO from JAVA.
public class User{ private String name; //other property private List
address; //getter setter }public class Address{ public String city; public String state; }
Now from UI side I have to dynamically add multiple address by click on addnew button from UI so new address row will be display on UI.
when I click on save all data will be pass as form.
I am not able to set address as list in form for User POJO.
Hello HiteshR,
At the following url, you can find information on Data Binding - Collection and selection.
http://books.zkoss.org/zk-mvvm-book/8.0/databinding/collectionand_selection.html
Thus can bind directly with the Address class, and save together the data.
Best Regards,
Darksu
Hi Darksu Thank you very much for help. Below is my code for adding multiple row but 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>
Thanks, Hitesh
Asked: 2016-07-06 03:53:28 +0800
Seen: 54 times
Last updated: Jul 18 '16
How to control selectAll() feature in a Listbox with multiple=true and checkmark=true
ZK8 Wizard Series: Part 2 now released!
Faster And Lighter, The Performance Test On ZK8
org.zkoss.xel.XelException: Resource not found: http://www.zkoss.org/dsp/web/core
How To Check Dirty Status in ZK8?
Come and join the ''JS'' Hunt!
Hi Darksu
Thank you very much for help.
I followed below example for test
http://blog.zkoss.org/2015/02/03/zk8-new-form-binding-approach/ https://github.com/zkoss-demo/zk8-formbinding-demo
But for Category list I set constraint for Category but it is not working.
Thanks, Hitesh
HiteshR ( 2016-07-06 11:57:20 +0800 )edit