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

Stackoverflow when template variable has the same name as view model property

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 8.0.1, 8.0.2
    • Databind
    • None
    • ZK 8.0.1.1
      Ubuntu
      Glassfish 4.1.1
      Java 8

      When the variable name of a template matches a viewmodel property name, there may be a stackoverflow when the content of that property changes.

      Zul:

      <zk xmlns="http://www.zkoss.org/2005/zul">
      <div apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.TestViewModel')" >
      <template name='tmplt'>
      <selectbox model="@bind" selectedItem="@bind(selected)">
      <template name='model'>
      <label value='${each}' />
      </template>
      </selectbox>
      </template>
      <apply template='tmplt' x="@load(vm.model)" selected="@ref(vm.selected)"/>
      <label value="@load(vm.selected)" />
      </div>
      </zk>

      ViewModel:

      package test;
      public class TestViewModel {

      List<String> model = new LinkedList<String>();
      private String selected;

      @Init
      private void init()

      Unknown macro: { model.add("1"); model.add("2"); model.add("3"); model.add("4"); model.add("5"); }

      public ListModelList<String> getModel()

      Unknown macro: { return new ListModelList(model); }

      public String getSelected()

      Unknown macro: { return selected; }

      public void setSelected(String selected)

      Unknown macro: { this.selected=selected; }

      }

      Try to change the value of the selectbox and you will get the following error:

      at java.util.HashMap.putVal(HashMap.java:628)
      at java.util.HashMap.put(HashMap.java:611)
      at java.util.HashSet.add(HashSet.java:219)
      at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
      at org.zkoss.bind.tracker.impl.TrackerImpl.getAllTrackerNodesByBean0(TrackerImpl.java:549)
      at org.zkoss.bind.tracker.impl.TrackerImpl.getAllTrackerNodesByBeanNodes(TrackerImpl.java:563)
      at org.zkoss.bind.tracker.impl.TrackerImpl.getAllTrackerNodesByBean0(TrackerImpl.java:553)
      at org.zkoss.bind.tracker.impl.TrackerImpl.getAllTrackerNodesByBeanNodes(TrackerImpl.java:563)
      at org.zkoss.bind.tracker.impl.TrackerImpl.getAllTrackerNodesByBean0(TrackerImpl.java:553)

      On zkfiddle:
      http://zkfiddle.org/sample/2n508lb/4-stackoverflow-example

            Unassigned Unassigned
            FloR FloR
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: