what it entails is something like this
wrappermodel extends model {
private IModel delegate;
setObject(Object o) {
Item item=(Item)o;
delegate.setObject(item.getid());
}
Object getObject() {
// this is the tricker one
String id=delegate.getObject();
Item item=...... // <=== find item with this id
return item;
}
}
or you can do the inverse, implement your own IChoiceRenderer which might actually be simpler. the choice renderer can do the opposite of what the model does.
-Igor
On 3/1/06, Scott Sauyet <[EMAIL PROTECTED]> wrote:
Igor Vaynberg wrote:
> your list consists of Items, but the model object that the choice
> component is bound to is a String. wicket expects the model object's
> type be the same as the item type in the list, thus the problem.
I told you my brain was getting fuzzy.
> [ ...]
>
> either change your model to contain an item, or write a model that will
> convert from id to the object, kinda like the inverse of the choice
> renderer.
Thank you. I had just gotten to that realization. I was in the middle
of writing an email to explain my findings. I didn't say it half as
well as you, though, so I think I'll scrap it.
I'm still trying to figure out the best way to proceed. I really like
having my model be a thin wrapper around my POJO, but that POJO is
itself a wrapper around a set of Strings supplied by a mainframe
program. So I don't really have a very semantic model, and can't easily
use a more meaningful class than String. I guess that leaves me with
making the wrapper model a bit thicker.
Are there any good examples of adapter models such as you describe?
-- Scott
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
