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

Invoke binder.loadAll() when the onChange event of the combobox will cause java error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 6.0.2
    • Fix Version/s: 6.0.5, 6.5.3
    • Component/s: Databind
    • Security Level: Jimmy
    • Labels:
      None

      Description

      <zk>
      	<window apply="test.ComboTestComposer">
      		<combobox model="@{ctl.list}" 
      				selectedItem="@{ctl.selItem}" 
      			    forward="onChange=onSelectItem" width="300px" readonly="true">
      		<comboitem self="@{each=item}" value="@{item}" label="@{item.name}"></comboitem>
      	</combobox>
      	</window>
      </zk>
      
      package test;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import org.zkoss.zk.ui.Component;
      import org.zkoss.zk.ui.event.Event;
      import org.zkoss.zk.ui.util.GenericForwardComposer;
      import org.zkoss.zkplus.databind.AnnotateDataBinder;
      
      public class ComboTestComposer extends GenericForwardComposer {
      	private AnnotateDataBinder binder;
      	private Item selItem;
      	private List<Item> list;
      
      	@Override
      	public void doAfterCompose(Component comp) throws Exception {
      		super.doAfterCompose(comp);
      		binder = new AnnotateDataBinder(comp);
      		comp.setAttribute("ctl", this);
      
      		list = new ArrayList<Item>();
      		list.add(new Item("Item 1"));
      		list.add(new Item("Item 2"));
      		list.add(new Item("Item 3"));
      		binder.loadAll();
      	}
      
      	public void onSelectItem(Event event) {
      		binder.loadAll();
      	}
      
      	public List<Item> getList() {
      		return list;
      	}
      
      	public void setList(List<Item> list) {
      		this.list = list;
      	}
      
      	public Item getSelItem() {
      		return selItem;
      	}
      
      	public void setSelItem(Item selItem) {
      		this.selItem = selItem;
      	}
      	
      	public static class Item {
      		private String name;
      
      		public Item(String name) {
      			super();
      			this.name = name;
      		}
      
      		public String getName() {
      			return name;
      		}
      
      		public void setName(String name) {
      			this.name = name;
      		}
      	}
      
      }
      
      

      ZK 5 works fine, it could be the side effect of http://tracker.zkoss.org/browse/ZK-1202

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: