> Label dbl = new Label("dbllbl",""+x){
Why pass in a string? Better is to do new Label("foo", new Model(x));
> @Override
> protected void onComponentTagBody(final MarkupStream
> markupStream, final
> ComponentTag openTag)
> {
> Object val =
> getConverter().convert(getModelObjectAsString(),
If you are merely displaying the value, you don't need to convert.
What this line above does - if you'd pass in a model that produces a
number) is convert from a number to a string (using the converter,
this is in getModelObjectAsString) and back again. You can just do
Object val = getModelObject().
Alternatives:
1) Wrap the model (decorator pattern) so that it returns the formatted value.
2) Use a custom converter like:
new Label("foo", new Model(x)) {
public IConverter getConverter(Class type) {
return new AbstractNumberConverter() {
public NumberFormat getNumberFormat(Locale locale) {
return NumberFormat.getCurrencyInstance();
}
}
}
}
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]