ZK ListBox Bug on Select All with Check Mark true

asked 2014-09-20 07:56:15 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8

Look at the ZKFiddle Code here

  1. Run the code.
  2. Click Select All Button
  3. All the Records will be selected.
  4. Now try to click Next button in the pagination. It will not move to next set of records. is this bug ?
delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted

answered 2014-09-20 09:58:25 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Senthilchettyin,

I performed a number of modifications to your code so it can work as expected:

The zul file:

<window title="Example for ZK MVVM List Box" width="500px"
 viewModel="@id('vm') @init('pkg$.ListBox2')">
 <label value="You are using: ${desktop.webApp.version}" />
 <listbox id="personsLstbx" model="@load(vm.allPersons)" checkmark="true" mold="paging" pageSize="3"
       <listhead sizable="true">
         <listheader label="First Name" sortDirection="ascending"
             sort="auto(firstName)" />
            <listheader label="Last Name" sort="auto(lastName)" />
            <listheader label="Email" sort="auto(email)" />
       <template name="model" var="p1">
                <listcell label="@load(p1.firstName)" />
              <listcell label="@load(p1.lastName)" />
               <listcell label="@load(p1.email)" />
    <button label="Select All"

And the java class:

package pkg$;

import java.util.ArrayList;
import java.util.List;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Listbox;

public class ListBox2  {

  private Listbox personsLstbx;

  private List<person> allPersons = new ArrayList<person>();
  private person selectedPerson;
  private List<person> selectedPersons;

  public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {

      Selectors.wireComponents(view, this, false);


    public person getSelectedPerson() {
     return selectedPerson;

   public void setSelectedPerson(person selectedPerson) {
      this.selectedPerson = selectedPerson;

   public List<person> getSelectedPersons() {
        return selectedPersons;

   public void setSelectedPersons(List<person> selectedPersons) {
        this.selectedPersons = selectedPersons;

   public List<person> getAllPersons() {
     return allPersons;

   public void setAllPersons(List<person> allPersons) {
      this.allPersons = allPersons;

   public ListBox2() {

     allPersons.add(new person("John 1", "James", "JohnJames@yahoo.com"));
     allPersons.add(new person("Taylor 2", "Harris", "Harris@yahoo.com"));
     allPersons.add(new person("Allen 3", "Scott", "Scott@yahoo.com"));
       allPersons.add(new person("John 4", "James", "JohnJames@yahoo.com"));
     allPersons.add(new person("Taylor 5", "Harris", "Harris@yahoo.com"));
     allPersons.add(new person("Allen 6", "Scott", "Scott@yahoo.com"));
       allPersons.add(new person("John 7", "James", "JohnJames@yahoo.com"));
     allPersons.add(new person("Taylor 8", "Harris", "Harris@yahoo.com"));
     allPersons.add(new person("Allen 9", "Scott", "Scott@yahoo.com"));


      public void onSelectAll()
      this.selectedPersons = new ArrayList<person>();

        for (person p: allPersons) {


   // inner class
  public class person {
       private String firstName;
       private String lastName;
        private String email;

       public person(String firstName, String lastName, String email) {
            this.firstName = firstName;
         this.lastName = lastName;
           this.email = email;

       public String getFirstName() {
          return firstName;

       public void setFirstName(String firstName) {
            this.firstName = firstName;

       public String getLastName() {
           return lastName;

       public void setLastName(String lastName) {
          this.lastName = lastName;

       public String getEmail() {
          return email;

       public void setEmail(String email) {
            this.email = email;


The problem was that there was a conflict when you set both selectedItem, and selectedItems (You only need selectedItems).

Best Regards,


link publish delete flag offensive edit


Thank you. But still it is ZK BUG ? Because in some cases, i need both selectedItem and SelectedItems

Senthilchettyin ( 2014-09-20 13:27:57 +0800 )edit
Your answer
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

1 follower



Asked: 2014-09-20 07:56:15 +0800

Seen: 22 times

Last updated: Sep 20 '14

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