Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-758

Unable to NotifyChange with indirect reference on an Array/List

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 6.0.0, Freshly
    • Fix Version/s: 6.0.0
    • Component/s: Databind 2
    • Labels:
      None

      Description

      @NotifyChange with indirect property does not work!

      IndirectNotifyChange.java


      public class IndirectNotifyChangeVM {
      private List<Person> _persons;

      public IndirectNotifyChangeVM() {
      _persons = new ListModelList<Person>();
      for(int j = 0; j < 4; ++j)

      { _persons.add(new Person("First"+j , "Last"+j)); }

      }

      public List<Person> getPersons()

      { return _persons; }

      @Command @NotifyChange("persons[0]")
      public void chang1stPerson()

      { _persons.set(0, new Person("Henri", "Chen")); }

      @Command @NotifyChange("persons[0].firstName")
      public void change1stPersonFirstName()

      { _persons.get(0).setFirstName("Tom"); }

      }

      indirect-notify-change.zul


      <window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.IndirectNotifyChangeVM')">
      NotifyChange via indirect [] on a List.
      Press "change first name of the first person", the first name of the first person shall change to "Tom".
      Press "change first person", the first person shall change to "Henri Chen".
      <grid width="500px" model="@bind(vm.persons)">
      <columns>
      <column label="First Name"></column>
      <column label="Last Name"></column>
      <column label="Full Name"></column>
      </columns>
      <template name="model" var="p">
      <row>
      <textbox value="@bind(p.firstName)"/>
      <textbox value="@bind(p.lastName)"/>
      <label value="@bind(p.fullName)"/>
      </row>
      </template>
      </grid>
      <button label="change first name of the first person" onClick="@command('change1stPersonFirstName')" />
      <button label="change first person" onClick="@command('chang1stPerson')" />
      <button label="Dump" onClick="binder.getTracker().dump()"/>
      </window>

        Attachments

          Activity

            People

            Assignee:
            henrichen henrichen
            Reporter:
            henrichen henrichen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: