0

How to check dirty in listbox, if my listcell value has changed ?

asked 2015-03-02 04:10:35 +0800

giovanni910 gravatar image giovanni910 flag of Indonesia
1 2

updated 2015-03-02 04:14:14 +0800

Hello friends, I have a problem to get a dirty status of my form. I had initialize the form to window in zul. Inside that window I created a dynamic listbox.. How can I get a dirty status, each time I made a change in the listbox value..

to change listbox value i made a new tag window in that zul, so i have two window in one zul.

Here is my example code..

<window apply="org.zkoss.bind.BindComposer" mode="modal"
  viewModel="@id('vm') @init('ui.master.EmployeeVmd')"
  form="@id('fx') @init(vm.formMaster) @load(vm.employee) @save(vm.employee, before='save')">
     <grid>
         <columns>
           <column width="130px" align="left" />
           <column width="250px" />
         </columns>
         <rows>
           <row>
             <label value="Name" />
             <textbox width="100px" value="@bind(fx.empName)"/>
            </row>
         </rows>
      </grid>

    <hlayout>
      <button label="save" onClick="@command('addDetail')" />
      <button label="save" onClick="@command('editDetail')" />
    <hlayout>

    <listbox model="@bind(vm.employee.address)" selectedItem="@bind(vm.address)">
      <listhead sizable="true">
         <listheader label="Street" sort="auto(street)" align="center" />
      </listhead>
        <template name="model">
          <listitem>
            <listcell label="@bind(each.streetName)" />
          <listitem>
        </template>
     </listbox>

 <window visible="@load(vm.winDetailShow)" mode="modal" width="32%"
   form="@id('fy') @init(vm.formDetail) @load(vm.address)
   @save(vm.address, before='confirmDetail')">
   <hbox width="100%">
     <button label="cancel" onClick="@command(fyStatus.dirty? 'showDirty' : 'back')" />
     <button label="save" onClick="@command('confirmDetail')" />
   </hbox>

  <grid>
     <columns>
       <column width="130px" align="left" />
       <column width="250px" />
     </columns>
     <rows>
       <row>
         <label value="Street" />
         <textbox width="100px" value="@bind(fy.streetName)"/>
        </row>
     </rows>
    </grid>
  </window>
</window>

and my view model

public class EmployeeVmd {

private Employee employee;
private Address address;

private Form formMaster = new SimpleForm();
private Form formDetail = new SimpleForm();

private boolean winDetailShow;

--some method--

@command("addDetail")
@NotifyChange({ "winDetailShow"})
public void addDetail(){
  ----some logic----
  winDetailShow = true;
}

@command("editDetail")
@NotifyChange({ "winDetailShow"})
public void editDetail(){
----some logic----
  winDetailShow = true;
}

@command("confirmDetail")
@NotifyChange({ "winDetailShow"})
public void confirmDetail(){
  ----some logic----
  employee.getAddress().add(address);
  winDetailShow = false;
}

}

how can i get the dirty if i add or edit detail in listbox when i confirm detail?

Thanks for answer.

delete flag offensive retag edit
Be the first one to answer this question!
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: 2015-03-02 04:10:35 +0800

Seen: 14 times

Last updated: Mar 02 '15

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