You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Swinsburg <s....@lancaster.ac.uk> on 2008/11/11 14:17:28 UTC
internationalising error messages
Is there a way to internationalise the error messages? I'd like them
to come from my resource bundle:
error(new ResourceModel("error.empty.file.uploaded"));
doesnt work and gives:
Model:classname=[org.apache.wicket.model.ResourceModel]
as the output. Alternatively I'll need to look at using a custom panel
to render my messages in one spot.
cheers,
Steve
Overriding builtin error messages
Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
I'd like to override the default form feedback messages (also so I can
localise them). ie
'Upload must be less than'
In Form.java I found this :
// Resource key should be <form-id>.uploadTooLarge to
// override default message
But I'm still not sure how to override it in a Properties file if the
form-id is dynamic?
Any help much appreciated.
Steve
Re: internationalising error messages
Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
Hi Jurrie,
Interesting. The property was in my main Application properties file,
not in the properties for the class that threw this error (lets say
TestPage.java). I'm not too keen on having multiple properties files
for lots of different Classes so I keep them all in one spot, I was
under the understanding it was meant to cascade up the tree? Does
Component's getString() method not cascade for properties?
If they are both just as localisable, I'm happy ;)
cheers,
Steve
On 11 Nov 2008, at 14:12, Jurrie Overgoor wrote:
> Steve Swinsburg wrote:
>> That throws a java.util.MissingResourceException: Unable to find
>> resource: error.empty.file.uploaded for component: .....
>>
>> Is there a reason why StringResourceModel is not preferred. Its
>> just as localisable as the other method right?
>
> I'm not saying that StringResourceModel is less preferred. They are
> both just as localisable. (Perhaps under the hood both methods boil
> down to the same thing?)
>
> I'm just saying that I mostly see examples that use Component's
> getString() method :)
>
> Why the MissingResourceException is thrown is a little unclear to
> me. Are you sure that the resource is in the correct file?
> getString() should load the string from the
> corresponding .properties file. So, if the code was in
> HelloWorld.java, then HelloWorld.properties should contain a line
> like error.empty.file.uploaded = You have uploaded an empty file.
>
> --
> With kind regards,
> Jurrie Overgoor
> 2go-mobile b.v.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
Re: internationalising error messages
Posted by Jurrie Overgoor <ju...@2go-mobile.nl>.
Steve Swinsburg wrote:
> That throws a
> java.util.MissingResourceException: Unable to find resource:
> error.empty.file.uploaded for component: .....
>
> Is there a reason why StringResourceModel is not preferred. Its just
> as localisable as the other method right?
I'm not saying that StringResourceModel is less preferred. They are both
just as localisable. (Perhaps under the hood both methods boil down to
the same thing?)
I'm just saying that I mostly see examples that use Component's
getString() method :)
Why the MissingResourceException is thrown is a little unclear to me.
Are you sure that the resource is in the correct file? getString()
should load the string from the corresponding .properties file. So, if
the code was in HelloWorld.java, then HelloWorld.properties should
contain a line like error.empty.file.uploaded = You have uploaded an
empty file.
--
With kind regards,
Jurrie Overgoor
2go-mobile b.v.
Re: internationalising error messages
Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
That throws a
java.util.MissingResourceException: Unable to find resource:
error.empty.file.uploaded for component: .....
Is there a reason why StringResourceModel is not preferred. Its just
as localisable as the other method right?
Steve
On 11 Nov 2008, at 13:34, Jurrie Overgoor wrote:
> Steve Swinsburg wrote:
>> Cool, ended up doing this:
>>
>> error(new StringResourceModel("error.empty.file.uploaded", this,
>> null).getString());
>>
>> Reckon thats the best solution? It's a bit heavier than just
>> ResourceModel, for simple strings with no param substitution would
>> it still be ok?
>
> I suppose it would work, but I think in Wicket you are ment to do:
>
> error(getString("error.empty.file.uploaded"));
>
> --
> Met vriendelijke groet,
> Jurrie Overgoor
> 2go-mobile b.v.
> t: +31 570 609 910
> f: +31 877 844 210
> e: jurrie.overgoor@2go-mobile.nl
> w: www.2go-mobile.nl
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
Re: internationalising error messages
Posted by Jurrie Overgoor <ju...@2go-mobile.nl>.
Steve Swinsburg wrote:
> Cool, ended up doing this:
>
> error(new StringResourceModel("error.empty.file.uploaded", this,
> null).getString());
>
> Reckon thats the best solution? It's a bit heavier than just
> ResourceModel, for simple strings with no param substitution would it
> still be ok?
I suppose it would work, but I think in Wicket you are ment to do:
error(getString("error.empty.file.uploaded"));
--
Met vriendelijke groet,
Jurrie Overgoor
2go-mobile b.v.
t: +31 570 609 910
f: +31 877 844 210
e: jurrie.overgoor@2go-mobile.nl
w: www.2go-mobile.nl
Re: internationalising error messages
Posted by Steve Swinsburg <s....@lancaster.ac.uk>.
Cool, ended up doing this:
error(new StringResourceModel("error.empty.file.uploaded", this,
null).getString());
Reckon thats the best solution? It's a bit heavier than just
ResourceModel, for simple strings with no param substitution would it
still be ok?
cheers,
Steve
On 11 Nov 2008, at 13:24, James Carman wrote:
> Component has a getString() method that you can use to access its
> message bundle.
>
> On Tue, Nov 11, 2008 at 8:17 AM, Steve Swinsburg
> <s....@lancaster.ac.uk> wrote:
>> Is there a way to internationalise the error messages? I'd like
>> them to come
>> from my resource bundle:
>> error(new ResourceModel("error.empty.file.uploaded"));
>> doesnt work and gives:
>> Model:classname=[org.apache.wicket.model.ResourceModel]
>> as the output. Alternatively I'll need to look at using a custom
>> panel to
>> render my messages in one spot.
>>
>> cheers,
>> Steve
>>
>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: internationalising error messages
Posted by James Carman <ja...@carmanconsulting.com>.
Component has a getString() method that you can use to access its
message bundle.
On Tue, Nov 11, 2008 at 8:17 AM, Steve Swinsburg
<s....@lancaster.ac.uk> wrote:
> Is there a way to internationalise the error messages? I'd like them to come
> from my resource bundle:
> error(new ResourceModel("error.empty.file.uploaded"));
> doesnt work and gives:
> Model:classname=[org.apache.wicket.model.ResourceModel]
> as the output. Alternatively I'll need to look at using a custom panel to
> render my messages in one spot.
>
> cheers,
> Steve
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org