You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Warren Bell <wa...@clarksnutrition.com> on 2013/12/11 21:10:09 UTC

How do I access Wicket's string resources in a non component class ?

I want to access Wicket's string resources in a non component class. I am aware of getLocalizer().getString(...) for a component, but how do you do this in a non Component based class and how do you make Wicket aware of the message bundle ? All of the Localizer#getString(...) methods require a Component. I am using Wicket version 6.10.0. I have a REST resource named UserResource.java and messages in UserResource.properties.

Thanks

Warren
-- 
This email was Virus checked by Clark's Nutrition's Astaro Security Gateway.

&lt;div style='font-size:11.0pt;font-family:&quot;Tahoma&quot;'&gt;The information contained in this e-mail is intended only for use of
the individual or entity named above. This e-mail, and any documents,
files, previous e-mails or other information attached to it, may contain
confidential information that is legally privileged. If you are not the
intended recipient of this e-mail, or the employee or agent responsible
for delivering it to the intended recipient, you are hereby notified
that any disclosure, dissemination, distribution, copying or other use
of this e-mail or any of the information contained in or attached to it
is strictly prohibited. If you have received this e-mail in error,
please immediately notify us by return e-mail or by telephone at
(951)321-1960, and destroy the original e-mail and its attachments
without reading or saving it in any manner. Thank you.&lt;/div&gt;

&lt;div align=&quot;center&quot; style='font-size:12.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;'&gt;&lt;strong&gt;Clark’s Nutrition is a registered trademark of Clarks Nutritional Centers, Inc.&lt;/strong&gt;&lt;/div&gt;

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


Re: How do I access Wicket's string resources in a non component class ?

Posted by Warren Bell <wa...@clarksnutrition.com>.
Answered my own question. Found this in Wicket REST Annotation tests. 

DefaultBundleResolver resolver = new DefaultBundleResolver(RestResourceFullAnnotated.class); 
                assertEquals(resolver.getMessage("CustomValidator", Collections.EMPTY_MAP), response);


On Dec 11, 2013, at 2:26 PM, Warren Bell wrote:

> I think this is exactly what I am looking for. I had an older version of Wicket REST Annotations that did not have this class.
> 
> I do have a question about its usage. I did the following in my resource class and it does work.
> 
> DefaultBundleResolver  defaultBundleResolver = new DefaultBundleResolver(MyRestResource.class);
> String message = defaultBundleResolver.getMessage("test", null);
> 
> Is this the correct way to use this class or is their a way for it to plug into Wicket via Application#Init() method and then get the Localizer and use it?
> 
> Thanks,
> 
> Warren
> 
> 
> On Dec 11, 2013, at 1:30 PM, Andrea Del Bene wrote:
> 
>> Hi,
>> 
>> maybe you can have a look here: https://github.com/wicketstuff/core/blob/master/jdk-1.6-parent/wicketstuff-restannotations-parent/restannotations/src/main/java/org/wicketstuff/rest/utils/wicket/bundle/DefaultBundleResolver.java
>> 
>> That's a resource bundle resolver that works with the stringResourceLoaders of the Application.
>>> I want to access Wicket's string resources in a non component class. I am aware of getLocalizer().getString(...) for a component, but how do you do this in a non Component based class and how do you make Wicket aware of the message bundle ? All of the Localizer#getString(...) methods require a Component. I am using Wicket version 6.10.0. I have a REST resource named UserResource.java and messages in UserResource.properties.
>>> 
>>> Thanks
>>> 
>>> Warren
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
>> -- 
>> This email was Virus checked by Clark's Nutrition's Astaro Security Gateway.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


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


Re: How do I access Wicket's string resources in a non component class ?

Posted by Warren Bell <wa...@clarksnutrition.com>.
I think this is exactly what I am looking for. I had an older version of Wicket REST Annotations that did not have this class.

I do have a question about its usage. I did the following in my resource class and it does work.

DefaultBundleResolver  defaultBundleResolver = new DefaultBundleResolver(MyRestResource.class);
String message = defaultBundleResolver.getMessage("test", null);

Is this the correct way to use this class or is their a way for it to plug into Wicket via Application#Init() method and then get the Localizer and use it?

Thanks,

Warren


On Dec 11, 2013, at 1:30 PM, Andrea Del Bene wrote:

> Hi,
> 
> maybe you can have a look here: https://github.com/wicketstuff/core/blob/master/jdk-1.6-parent/wicketstuff-restannotations-parent/restannotations/src/main/java/org/wicketstuff/rest/utils/wicket/bundle/DefaultBundleResolver.java
> 
> That's a resource bundle resolver that works with the stringResourceLoaders of the Application.
>> I want to access Wicket's string resources in a non component class. I am aware of getLocalizer().getString(...) for a component, but how do you do this in a non Component based class and how do you make Wicket aware of the message bundle ? All of the Localizer#getString(...) methods require a Component. I am using Wicket version 6.10.0. I have a REST resource named UserResource.java and messages in UserResource.properties.
>> 
>> Thanks
>> 
>> Warren
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> -- 
> This email was Virus checked by Clark's Nutrition's Astaro Security Gateway.


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


Re: How do I access Wicket's string resources in a non component class ?

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

maybe you can have a look here: 
https://github.com/wicketstuff/core/blob/master/jdk-1.6-parent/wicketstuff-restannotations-parent/restannotations/src/main/java/org/wicketstuff/rest/utils/wicket/bundle/DefaultBundleResolver.java

That's a resource bundle resolver that works with the 
stringResourceLoaders of the Application.
> I want to access Wicket's string resources in a non component class. I am aware of getLocalizer().getString(...) for a component, but how do you do this in a non Component based class and how do you make Wicket aware of the message bundle ? All of the Localizer#getString(...) methods require a Component. I am using Wicket version 6.10.0. I have a REST resource named UserResource.java and messages in UserResource.properties.
>
> Thanks
>
> Warren


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


Re: How do I access Wicket's string resources in a non component class ?

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you can pass a null component to Localizer's methods. You have to put 
the string resources in YourApplication.properties or 
YourInitializer.properties though.

Hope this helps
Sven


On 12/11/2013 09:10 PM, Warren Bell wrote:
> I want to access Wicket's string resources in a non component class. I am aware of getLocalizer().getString(...) for a component, but how do you do this in a non Component based class and how do you make Wicket aware of the message bundle ? All of the Localizer#getString(...) methods require a Component. I am using Wicket version 6.10.0. I have a REST resource named UserResource.java and messages in UserResource.properties.
>
> Thanks
>
> Warren


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