0

How to create two different form in one zul ??

asked 2014-08-15 03:44:24 +0800

giovanni910 gravatar image giovanni910 flag of Indonesia
1 2

updated 2014-08-15 03:46:07 +0800

Hello Friends, I want to have two validaton methode in one zul. One using a class validation and the others using methode in my viewModel. I separate the two with two different form id in my zul. The first one that using the class validation is working properly, but the other one isn't.

Can u help me out? Here is my zul code.

        <zk>
            <window title="${execution.attributes.pageInfo}"
            sclass="square black" mode="modal" width="1000px"
            apply="org.zkoss.bind.BindComposer"
            viewModel=" @id('vm') @init('ui.viewmodel.MyViewModel')"
            validationMessages="@id('vmsgs')">
                        <grid
                            form="@id('fx') @load(vm.masKarDto) @save(vm.masKarDto, before='save')
                                                         @validator('ui.common.KaryawanValidator')">
                            <columns>
                                <column width="130px" />
                                <column />
                                <column width="150px" />
                                <column width="130px" />
                                <column />
                                <column />
                            </columns>

                            <rows>
                                <row>
                                    <label value="KODE CABANG" />
                                    <cell colspan="2">
                                        <textbox width="200px"
                                            value="@bind(fx.kdprs)" />
                                        <label style="color:red" value="@load(vmsgs['errorFind1'])" />
                                    </cell>

                                    <label value="KODE JABATAN" />
                                    <cell colspan="2">
                                        <combobox form="@id('fy') @load(vm.masKarDto) @save(vm.masKarDto, before = 'save') @validator(vm.karyawanValidator)"
                                            model="@load(vm.masJabatanDtos)"
                                            selectedItem="@bind(fy.masJabatanDto)">
                                            <template
                                                name="model">
                                                <comboitem
                                                    label="@load(each.nmjab)" value="@bind(each.kdjab)" />
                                            </template>
                                        </combobox>
                                        <label style="color:red" value="@load(vmsgs['errorFind3'])" />
                                    </cell>
                                </row>
                            </rows>
                        </grid>
            </window>
        </zk>
delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-08-15 07:38:26 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

If you want to do validation in your zul for example the combobox you can do like this :

zul:

<combobox id="cbx" form="@id('fy') @load(vm.masKarDto) @save(vm.masKarDto, before = 'save')" model="@load(vm.masJabatanDtos)" selectedItem="@bind(fy.masJabatanDto)">
<button "@command('save',combobox = cbx)" />

VM:

@Command
public void save(@BindingParam("combobox") Combobox cbx) {
    if () { // your condition to check
        throw new WrongValueException(cbx,"your message");
    }
    // the rest of your save function.
link publish delete flag offensive edit
0

answered 2014-08-18 03:53:37 +0800

giovanni910 gravatar image giovanni910 flag of Indonesia
1 2

Hello Chillworld,

Btw sorry I late answer your post. Thank you for your answer, its very helpfull. But is that mean we dont need a ValidationContext to handle a validation? What is better?

link publish delete flag offensive edit

Comments

The validationcontext is still needed. because you use the validator ui.common.KaryawanValidator. Personlly I try to work without a validator and just put everything like : constraint="no empty", for ex textbox you could add regex and give them custom message,...

chillworld ( 2014-08-18 06:42:10 +0800 )edit
0

answered 2014-08-18 04:15:51 +0800

giovanni910 gravatar image giovanni910 flag of Indonesia
1 2

And how to show the message error in zul ?

link publish delete flag offensive edit

Comments

If you implemented the code like I said the errormessage is shown next to the combobox. (for that we needed to give the combobox as bindingparam)

chillworld ( 2014-08-18 06:44:13 +0800 )edit

Oke thank you so much for your help friend :)

giovanni910 ( 2014-08-19 07:10:27 +0800 )edit

your welcome

chillworld ( 2014-08-19 08:23:29 +0800 )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
2 followers

RSS

Stats

Asked: 2014-08-15 03:44:24 +0800

Seen: 35 times

Last updated: Aug 18 '14

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