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

Binder on create event bug

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Later Later
    • None
    • 6.0.1
    • Databind

      Hi,
      please try this code:

      <zscript><![CDATA[
      import org.zkoss.zk.ui.util.GenericForwardComposer;
      
      AnnotateDataBinder binder;
      
      class MyComposer extends GenericForwardComposer {
      
          Window w;
          Listbox lb;
      
          public void doAfterCompose(Component c) {
              super.doAfterCompose(c);
              binder = new AnnotateDataBinder(c);
          }
      
          public void onCreate$w() {
              List list = new ArrayList();
              list.add("first");
              list.add("second");
              binder.bindBean("model",list);
              binder.loadAll();
              System.out.println(lb.getModel().getSize());
          }
      }
      
      public void loadAll() {
          binder.loadAll();
      }
      ]]></zscript>
          <window id="w" title="hello" apply="MyComposer">
      
              <listbox id="lb" model="@{model}">
                  <listitem>
                      <listcell label="@{each}"/>
                  </listitem>
              </listbox>
              <button label="loadAll" onClick="loadAll()"/>
          </window>
      

      When the page loads the listbox model is not working correctly, if you watch the System.out.println() it shows "2" but in the listbox there are no item.
      I have to reload the component to make them appear (using the button).
      It worked correctly with zk 3.6.4 but not in 6.0.1.
      I need to bind beans in the onCreate method because in my code I need also the CreateEvent I left out here to simplify.
      Thanks

            Unassigned Unassigned
            mbarbieri mbarbieri
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: