StringResourceModel object value = null

2013-07-19 Thread Tommy Sadiq Hinrichsen
Hey

I'm using a Stringresourcemodel to display a custom message label. Its
constructed like this.

new Label(maxAmount, new
StringResourceModel(bookkeeping.amount.to.move,null, new Object[]{
new PropertyModel(this, valueReport.lastValuationDate),
new PropertyModel(this, valueReport.totalValueLocal),
new
PropertyModel(getCurrentSelections().getSelectedLegalEntity(),
bookkeepingCurrency)
})));

With the following entry in a property file

bookkeeping.amount.to.move=Booked value per {0,date} is {1,number,###.##}
{2}

My problem is that the valuereport object is not populated before the user
makes a choice on the page. So my label is showing like this

Booked value per null is null DKK

When i try to use  as default value in the constructor i get a conversion
error.
Caused by: java.lang.IllegalArgumentException: Cannot format given Object
as a Date

Anybody got any ideas?

Med venlig hilsen / Best regards

Tommy Sadiq Hinrichsen


Re: StringResourceModel object value = null

2013-07-19 Thread Sven Meier

Hi,

it's java.text.MessageFormat which renders null parameters as 'null'.

I'd suggest you use a custom model that uses two different 
StringResourceModels depending on the present parameters.


Sven

On 07/19/2013 10:13 AM, Tommy Sadiq Hinrichsen wrote:

Hey

I'm using a Stringresourcemodel to display a custom message label. Its
constructed like this.

new Label(maxAmount, new
StringResourceModel(bookkeeping.amount.to.move,null, new Object[]{
 new PropertyModel(this, valueReport.lastValuationDate),
 new PropertyModel(this, valueReport.totalValueLocal),
 new
PropertyModel(getCurrentSelections().getSelectedLegalEntity(),
bookkeepingCurrency)
 })));

With the following entry in a property file

bookkeeping.amount.to.move=Booked value per {0,date} is {1,number,###.##}
{2}

My problem is that the valuereport object is not populated before the user
makes a choice on the page. So my label is showing like this

Booked value per null is null DKK

When i try to use  as default value in the constructor i get a conversion
error.
Caused by: java.lang.IllegalArgumentException: Cannot format given Object
as a Date

Anybody got any ideas?

Med venlig hilsen / Best regards

Tommy Sadiq Hinrichsen




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org