You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Pat <pa...@aol.com> on 2012/12/07 20:04:12 UTC

Listview Checkbox checked by default and disapearing after submit

Hi,

I have searched for this problem and read many entries but I can't seem to
figure it out. I have two problems:

1. When instantiate my ListView with Check checkboxes they are always
checked by default. I can't manage to uncheck them by default.

2. Once I have chosen items from my list via the checkboxes and submitted
the form depending on how many checkboxes have been checked, that amount of
rows just disappears from the bottom of my list. It doesn't matter which
boxes I check, it's always the rows from the bottom up that disappear.

It would be really great if anyone could help, thanks you in advance.

Here is my code:

// initialize CheckGroup
        this.checkGroup = new CheckGroup("checkgroup", new
CompoundPropertyModel(this.someList));
        someForm.add(checkGroup);
        
        // initialize ListView
        this.listView = new ListView<String[]>("someList", new
CompoundPropertyModel(this.someList)) {

            @Override
            protected void populateItem(ListItem item) {
                String[] array = (String[]) item.getModelObject();
                item.add(new Check("checkbox", item.getModel()));
                item.add(new Label("label1", array[0]));
                item.add(new Label("label2", array[1]));
                item.add(new Label("label3", array[2]));
            }
        };
        this.listView.setReuseItems(true);
        checkGroup.add(this.listView);


protected void onSubmit() {
                LinkedList<String[]> list =
((LinkedList<String[]>)checkGroup.getModelObject());
                
                for(int i=0; i<list.size(); i++) {
                    //do stuff with the list
                }
            };



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Listview-Checkbox-checked-by-default-and-disapearing-after-submit-tp4654605.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Listview Checkbox checked by default and disapearing after submit

Posted by Pat <pa...@aol.com>.
Thank you so much, I would never have found that! Everything works perfectly
now

cheers



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Listview-Checkbox-checked-by-default-and-disapearing-after-submit-tp4654605p4654610.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Listview Checkbox checked by default and disapearing after submit

Posted by Sven Meier <sv...@meiers.net>.
> this.checkGroup = new CheckGroup("checkgroup", new CompoundPropertyModel(this.someList));
> ...
> this.listView = new ListView<String[]>("someList", new CompoundPropertyModel(this.someList))

Do you really want the list to iterate over the checked items only?
I'd expect these components to use different lists: one for all selected and one for all available

Sven



On 12/07/2012 08:04 PM, Pat wrote:
> Hi,
>
> I have searched for this problem and read many entries but I can't seem to
> figure it out. I have two problems:
>
> 1. When instantiate my ListView with Check checkboxes they are always
> checked by default. I can't manage to uncheck them by default.
>
> 2. Once I have chosen items from my list via the checkboxes and submitted
> the form depending on how many checkboxes have been checked, that amount of
> rows just disappears from the bottom of my list. It doesn't matter which
> boxes I check, it's always the rows from the bottom up that disappear.
>
> It would be really great if anyone could help, thanks you in advance.
>
> Here is my code:
>
> // initialize CheckGroup
>          this.checkGroup = new CheckGroup("checkgroup", new
> CompoundPropertyModel(this.someList));
>          someForm.add(checkGroup);
>          
>          // initialize ListView
>          this.listView = new ListView<String[]>("someList", new
> CompoundPropertyModel(this.someList)) {
>
>              @Override
>              protected void populateItem(ListItem item) {
>                  String[] array = (String[]) item.getModelObject();
>                  item.add(new Check("checkbox", item.getModel()));
>                  item.add(new Label("label1", array[0]));
>                  item.add(new Label("label2", array[1]));
>                  item.add(new Label("label3", array[2]));
>              }
>          };
>          this.listView.setReuseItems(true);
>          checkGroup.add(this.listView);
>
>
> protected void onSubmit() {
>                  LinkedList<String[]> list =
> ((LinkedList<String[]>)checkGroup.getModelObject());
>                  
>                  for(int i=0; i<list.size(); i++) {
>                      //do stuff with the list
>                  }
>              };
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Listview-Checkbox-checked-by-default-and-disapearing-after-submit-tp4654605.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org