ZK6 databinding with listmodel problem

asked 2012-01-31 06:03:10 +0800

M4tt gravatar image M4tt
39 5

updated 2012-01-31 08:38:34 +0800

I have a page using the new zk6 databinding feature, it contains a listbox and a viewmodel class.
The problem is when I use the viewmodel class to create a new database entity row,
the page will update all the entity content to the entity which I just created (only view, the origin entities in listmodel is fine).

For example, I have a list of entities with id 1 to 5, then I create a new entity id=6,
the page with automatic update all the entity content in the listbox to the entity[id=6]

only the content on the page is changed, everything else (include the entities in listModel) remains original.

And if the listbox has more than one page, it won't update all the entities to the newest entity until the newest entity is showed.

Any idea? Thank you.

here is the example of my viewmodel

public class ViewModel{

  private ListModelList listModel;
  private Entity selectedEntity;
  private EntityDao dao;
   public ViewModel() {
        EntityDao dao = new EntityDao();
        listModel = new ListModelList(dao.list());

   public Entity getSelectedEntity() {
        return selectedEntity;

    public void setSelectedEntity(Entity selectedEntity) {
        this.selectedEntity = selectedEntity;

  public boolean createEntity(Entity entity) {
         EntityDao dao = new EntityDao();
        boolean isSuccess = dao.create(entity);
        if (isSuccess) {
            return true;
        } else {
            return false;

    public ListModelList getListModel() {
        return listModel;

    public void setListModel(ListModelList listModel) {
        this.listModel= listModel;

my listbox snippet

  <window apply="org.zkoss.bind.BindComposer" vflex="true" viewModel="@id('vm') @init('ViewModel'))">
        <listbox id="list" model="@load(vm.listModel)" selectedItem="@bind(vm.selectedEntity)" hflex="true" mold="paging" multiple="false"  checkmark="true"
                                    <listheader hflex="min"></listheader>
                                    <listheader label="ID" hflex="min" sort="auto(id)"></listheader>
          <template name="model" var="entity">
              <listitem value="@bind(entity)">
                          <intbox value="@bind(entity.id)" inplace="true" constraint="no empty,no negative,no zero" width="120px"></intbox>

my create entity snippet

  <button label="Save Entity">
         <attribute name="onClick">
                    Entity entity = new Entity();
                    //skipped, get the entity information from a form
                    boolean isSuccess = vm.createEntity(entity);
                    //skipped,  post process.

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-02-02 04:28:51 +0800

M4tt gravatar image M4tt
39 5

The problem just disappeared after I've edited the zul and undone the change.
Nothing is changed (maybe...) but it's just gone.
Maybe it's an IDE problem...

link publish delete flag offensive edit
Your reply
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




Asked: 2012-01-31 06:03:10 +0800

Seen: 224 times

Last updated: Feb 02 '12

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