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

current page of PAGING LISTBOX or PAGING GRID after update model

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • None
    • Components

      after loading test.zul I have a listbox with 4 pages ... I move to page 4 and now click on tlbtn_test so the model of listbox is updated BUT ACTIVE PAGE REMAINS ON THE PAGE 4.
      this behavior (for me) seems illogical ... if I have PAGING LISTBOX, when I update/set the model by new search, the current page by default should be set to the first page without having to make: this.lst_test.setActivePage(0) !

      BTW, would be nice to have in new ZK 6 version an option/attribute in zul file to decide whether or not to return to the first page after set/updating the model of a PAGING LISTBOX or PAGING GRID.

      [test.zul]
      --------------------------------------------------------------------------------------------
      <zk xmlns:n="native" xmlns:h="xhtml" xmlns:zk="zk" xmlns:w="client">
      <window id="win_test" title="Test" border="normal" width="100%" height="100%"
      apply="it.fastbookspa.TestCtrl">

      <toolbarbutton id=" tlbtn_test " label="search"/>

      <separator bar="true" spacing="10px"/>

      <listbox id="lst_test" vflex="true" hflex="1"
      nonselectableTags="" mold="paging" pagingPosition="top" pageSize="25"
      model="@

      {win_test$composer.getListItem, load-after='tlbtn_test.onClick'}

      "
      selectedItem="@

      {win_test$composer .selectedItem}

      "
      emptyMessage="no items">

      <listhead>
      <listheader label="value" hflex="1" align="center"
      valign="top" />
      </listhead>

      <listitem self="@

      {each='item'}

      " value="@

      {item}">
      <listcell label="@{item}

      " />
      </listitem>
      </listbox>

      </win dow>
      </zk>
      --------------------------------------------------------------------------------------------

      [TestCtrl]
      --------------------------------------------------------------------------------------------
      package it.fastbookspa;
      import java.util.ArrayList;
      import java.util.List;

      import org.apache.log4j.Logger;
      import org.zkoss.zk.ui.Component;
      import org.zkoss.zk.ui.event.ForwardEvent;
      import org.zkoss.zk.ui.util.GenericForwardComposer;
      import org.zkoss.zkplus.databind.AnnotateDataBinder;
      import org.zkoss.zkplus.databind.BindingListModel;
      import org.zkoss.zkplus.databind.BindingListModelList;
      import org.zkoss.zul.Listbox;
      import org.zkoss.zul.Toolbarbutton;

      public class TestCtrl extends GenericForwardComposer {

      private static final long serialVersionUID = 1L;

      private static final Logger logger = Logger.getLogger(TestCtrl.class);

      protected AnnotateDataBinder _binder;

      private Integer selectedItem;

      private transient Toolbarbutton tlbtn_test;
      private transient Listbox lst_test;

      @Override
      public void doAfterCompose(Component comp) throws Exception

      { super.doAfterCompose(comp); this.lst_test.getPagingChild().setMold("os"); this._binder = new AnnotateDataBinder(comp); comp.setAttribute("binder",this._binder); this._binder.loadAll(); }

      //Binding

      public Integer getSelectedItem()

      { return this.selectedItem; }

      public void setSelectedItem(Integer selectedItem)

      { this.selectedItem = selectedItem; }

      public BindingListModel getListItem(){
      List<Integer> listItem = new ArrayList<Integer>();

      for (int i = 0; i < 100; i++)

      { listItem.add(i); }

      //this.lst_test.setActivePage(0);

      return new BindingListModelList(listItem, true);
      }

      //Events

      public void onClick$tlbtn_test(ForwardEvent event)

      { logger.debug("################onClick$tlbtn_test"); }

      public void onAfterRender$lst_test(ForwardEvent event)

      { logger.debug("################onAfterRender$lst_test::Active Page: " + ((Listbox)event.getOrigin().getTarget()).getActivePage()); }

      }
      --------------------------------------------------------------------------------------------

            SimonPai SimonPai
            smigol smigol
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: