setobject is called when the component needs to update the model. eg when
you submit a textfield it needs to push new input into the model and so it
calls setobject(). sometimes components that work with collections do not do
that - they simply clear the collection and add new values - this is so you
are in control of creating the collection - be it a set/list/etc.

-igor


On 3/12/07, David Leangen <[EMAIL PROTECTED]> wrote:


Igor,

Regarding your suggestions below:

> > 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.

Yes, it does indeed give me many ideas. Right now, I'm trying to figure
out the implementation details.

While stepping through the code, I noticed that the setObject() method
of my IModel never gets called.


When is this _supposed_ to be set, and why would it not be called in my
case?


Cheers,
David





-------------------------------------------------------------------------
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

Reply via email to