You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by akinsgre <an...@gmail.com> on 2010/08/24 16:51:09 UTC

Re: Any way to load resources in java.util.ResourceBundle

OK.. I dropped off this thread because some other fires sprang up at work..
but here I am back where I was a month ago.

struts.xml
<constant name="struts.custom.i18n.resources"
value="com.fiserv.sourceone.ribs.common.bundles.DbResourceBundle" />

index.jsp
<s:text name="FS_UI_ACCT_SWITCH_EN_BUTTON_GO_ACCOUNT"/>	

The value of "name" is output on the page, and the DbResourceBundle class
doesn't appear to be loaded.


J_e_f_f wrote:
> 
> D'oh! Yeah, that was a typo. Should say struts.xml.
> 
> Could you post some relevant code snippets? Also, do you see anything in
> the logs when the application starts up?  
> 
> Jeff
> 
> 
> Greg Akins-2 wrote:
>> 
>> On Fri, Jul 16, 2010 at 9:24 PM, J_e_f_f <ja...@gmail.com> wrote:
>>>
>>> If you're specifying your DbResourceBundle class in the web.xml like:
>> 
>>                        ^^^^^^^^
>>>
>>> <constant name="struts.custom.i18n.resources"
>>> value="com.insomnia.common.bundles.DbResourceBundle" />
>>>
>> 
>> Was that a typo?  Did you mean struts.xml?  I have it in struts.xml,
>> but it doesn't seem to be getting called.  Maybe it should be in
>> web.xml .. in that case as an init-param on the Dispatcher filter.
>> Right?
>> 
>> -- 
>> Greg Akins
>> 
>> http://insomnia-consulting.org
>> http://www.pghcodingdojo.org
>> http://pittjug.dev.java.net
>> http://twitter.com/akinsgre
>> http://www.linkedin.com/in/akinsgre
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Re%3A-Any-way-to-load-resources-in-java.util.ResourceBundle-tp29182865p29522847.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Any way to load resources in java.util.ResourceBundle

Posted by Greg Akins <an...@gmail.com>.
Yippee!!

After a little more Googling it occurred to me that the default might
be still set in struts.properties; it was.. and when I removed it my
DbResourceBundle started working

Thanks for bearing with me



-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Any way to load resources in java.util.ResourceBundle

Posted by Greg Akins <an...@gmail.com>.
On Tue, Aug 24, 2010 at 1:13 PM, Dale Newfield <da...@newfield.org> wrote:
>>>
>>> struts.xml
>>> <constant name="struts.custom.i18n.resources"
>>> value="com.fiserv.sourceone.ribs.common.bundles.DbResourceBundle" />
>
> That constant has a String value.

>From what I've read, the struts.custom.i18n.resources constant usually
gets set to something like "global-messages" which translates to a
.properties file.  However, at the beginning of this thread I asked
about using ResourceBundle which loads from a database, and this usage
was suggested to me.  I'm not  sure how Struts is reconciling that
constant.. but expected it would either load the class there, or wait
until the first usage.
>
>>> index.jsp
>>> <s:text name="FS_UI_ACCT_SWITCH_EN_BUTTON_GO_ACCOUNT"/>
>
> And this is looking up the specified item in ApplicationResources.properties

OK, and maybe that's the problem, because I expected it to use the
resource bundle from struts.custom.i18n.resources
>
>
>> A followup to this:
>>
>> If I put a static initializer with a System.out.println in
>> DbResourceBundle, it never get's executed;
>
> Or the output isn't going where you expect it to.
>

Yeah, maybe.. though if I load that class directly I do see it on my
console (running the app with mvn tomcat:run )



-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Any way to load resources in java.util.ResourceBundle

Posted by Dale Newfield <da...@newfield.org>.
On 8/24/10 12:54 PM, Greg Akins wrote:
> On Tue, Aug 24, 2010 at 10:51 AM, akinsgre<an...@gmail.com>  wrote:
>> struts.xml
>> <constant name="struts.custom.i18n.resources"
>> value="com.fiserv.sourceone.ribs.common.bundles.DbResourceBundle" />

That constant has a String value.

>> index.jsp
>> <s:text name="FS_UI_ACCT_SWITCH_EN_BUTTON_GO_ACCOUNT"/>

And this is looking up the specified item in 
ApplicationResources.properties


> A followup to this:
>
> If I put a static initializer with a System.out.println in
> DbResourceBundle, it never get's executed;

Or the output isn't going where you expect it to.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Any way to load resources in java.util.ResourceBundle

Posted by Greg Akins <an...@gmail.com>.
On Tue, Aug 24, 2010 at 10:51 AM, akinsgre <an...@gmail.com> wrote:
>
> struts.xml
> <constant name="struts.custom.i18n.resources"
> value="com.fiserv.sourceone.ribs.common.bundles.DbResourceBundle" />
>
> index.jsp
> <s:text name="FS_UI_ACCT_SWITCH_EN_BUTTON_GO_ACCOUNT"/>
>

A followup to this:

If I put a static initializer with a System.out.println in
DbResourceBundle, it never get's executed; I'm not sure when I should
expect the class to get loaded, but it seems like the constant
declaration isn't doing anything right now.

-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org