0

Multiple row constraint in form MVVM

asked 2016-07-08 22:16:03 +0800

HiteshR gravatar image HiteshR
1 2

updated 2016-07-08 22:17:46 +0800

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

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-07-17 02:47:43 +0800

jeanca93 gravatar image jeanca93
1 1

Link is broken, perhaps you can show some of your code to guide you

link publish delete flag offensive edit
0

answered 2016-07-18 18:34:43 +0800

HiteshR gravatar image HiteshR
1 2

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>

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-07-08 22:16:03 +0800

Seen: 33 times

Last updated: Jul 18 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More