looks fine, the only minor tweak i would do is that since the check
box model is inner nonstatic class it probably has access to the
selected set already, so prob no need to pass it in.

-igor


On Jan 8, 2008 3:46 AM, Alan Romaniuc <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> A dummy question, or suggestion... I am new to Wicket and i trying to
> understanding it.
>
> I have a form with a Paginated DataView and I would like to use checkbox
> (something like "old" WebMails) to select rows, and a delete button, so
> I can delete multiple lines at a time.
>
> Right now I am doing something like this:
>
> /////////////////////////////////////////////////CODE/////////////////////////////////////////////////////////////
> public class InfoList extends WebPage {
>     ......
>     Form f = new InfoDataForm("form",infoProvider);
>
>     private class InfoDataForm extends Form {
>
>         SortableDataProvider dp;
>
>         HashSet<Long> selectedValues = new HashSet<Long>();
>
>         ChequeListForm(String id, SortableDataProvider dp) {
>
>             super(id);
>             this.dp = dp;
>
>             final DataView infoDataView = new DataView("infoList", dp) {
>                 @Override
>                 protected void populateItem(Item item) {
>                     Info info = (Info) item.getModelObject();
>                     item.add(new CheckBox("check", new
> SelectItemUsingCheckboxModel(info,selectedValues)));
>                     item.add(new Label("data1", info.data1()));
>                     item.add(new Label("data2", info.data2()));
>                 }
>             }
>
>             add(infoDataView);
>
>             @Override
>             protected void onSubmit() {
>                 super.onSubmit();
>                 for (Long i: selectedValues) {
>                     System.out.println(i);
>                     //delete rows here
>                 }
>             }
>         }
>
>
>     private class SelectItemUsingCheckboxModel extends
> AbstractCheckBoxModel {
>
>         private final Info info;
>         private Set selection;
>
>         public SelectCheckByChequeModel(Info info, Set selection) {
>             this.info = info;
>             this.selection = selection;
>          }
>
>         @Override
>         public boolean isSelected() {
>             return selection.contains(info);
>         }
>
>         @Override
>         public void select() {
>             selection.add(info);
>         }
>
>         @Override
>         public void unselect() {
>             selection.remove(info);
>         }
>     }
> }
>
> //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> I believe that I used the dataview and dataprovider correctly, but I am
> not sure about
> checkbox...
> Once I am learning, I would like to know if this is "the correct way" to
> do that, or if not,
> what I should do...
>
>
> Thanks a lot
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to