Still playing around with this, and I have a question. When does the IModel's setObject() method get called?
I'm stepping through the code, but this method is never being called... Cheers, Dave On Fri, 2007-03-09 at 16:47 -0600, Thomas R. Corbin wrote: > On Friday, 09 March 2007 11:57 am, Igor Vaynberg escreveu: > > yes, but then you are married to the output it genereates. > > > > [] label > > [] label > > > > whats below you can use just for the checkbox, so you are free to generate > > your own label/panel/whatever. eg selecting rows in a table. > > Ooooh - thanks! > > > > > -igor > > > > On 3/9/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote: > > > On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu: > > > > see above. take a simple example where you have a list of checkboxes > > > > and you want all selected objects to end up in a collection. how do you > > > > do > > > > > > it? > > > > > > > sounds like a complex mapping? the most elegant way is to write a > > > > custom model. > > > > > > Can you use a CheckBoxMultipleChoice for this? > > > > > > > class mypage extends page { > > > > private Set<Person> selected=new HashSet(); > > > > > > > > private class PersonCheckboxModel implements IModel<Boolean> { > > > > private final IModel<Person> person; > > > > public final PersonCheckBoxModel(IModel<Person> person) { > > > > this.person=person; } > > > > > > > > public Boolean getObject() { > > > > return selected.contains(person.getObject()); > > > > } > > > > > > > > public void setObject(Boolean b) { > > > > if (Boolean.TRUE.equals(b)) { > > > > selected.put(person.getObject()); > > > > } else { > > > > selected.remove(person.getObject()); > > > > } > > > > } > > > > > > > > public void detach() { person.detach(); } > > > > } > > > > > > > > } > > > > > > > > now all you have to do is > > > > > > > > LoadableDetachableModel person=new LoadalbeDetachableModel(id); > > > > new CheckBox(this, "cb", new PersonCheckBoxModel(person)); > > > > > > > > and everything magically works, hope it gives you some ideas. > > > > > > ------------------------------------------------------------------------- > > > Take Surveys. Earn Cash. Influence the Future of IT > > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > > your > > > opinions on IT & business topics through brief surveys-and earn cash > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > _______________________________________________ > > > Wicket-user mailing list > > > Wicket-user@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user