Reputation: 2030
I have a Java Map
where I store data that has to be shown in a row in a table in a web application. I am using Wicket 6.
Is there a way to link Wicket Labels (which will be cells in my table) to the String
version of an object in a Map
knowing the key for each Label.
Should I implement my own version of IModel
or is there any convenience class in the Wicket 6 libraries? As far as I can see there is none, but I could be wrong...
Upvotes: 0
Views: 1157
Reputation: 20019
I think there is no such IModel
implementation at the current moment. It is not too hard to write your own IModel<String>
that takes your Map
and a key
in the constructor and return the String.valueOf(map.get(key))
;)
Just make sure that either your Map
is Serializable
or otherwise, you should provide a LoadableDetachableModel
for your map and use that.
Upvotes: 0
Reputation: 739
You can implement IModel
also you can implement IConverter<C>
.
To use custom converter override Component#getConverter
like so:
Label lbl = new Label("lbl"){
@Override
public <C> IConverter<C> getConverter(Class<C> type) {
//return converter here
}
};
For components like Label
you can implement only convertToString
method.
Upvotes: 1