• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resource Bundle files by Modules setup

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

Here is the scenario :

I have two resource bundles files, ApplicationResources-co.properties and ApplicationResources-po.properties, for co modules and po modules respectively. And there is ApplicationResources.properties for default.

And I have two struts-config.xml files for the above two modules, which is struts-co-config.xml and struts-po-config.xml file.

The problem right now, struts cannot find out the name/value mapping in ApplicationResources-po/co.properties. It only searches in the default file, ApplicationResources.properties.

can anyone how I should config. so that struts can also search the key in the other two resources bundle files?

I am using struts 1.1


Thanks
Benson
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inside your Web Module, take WSAD as an example, you should have 2 directories: JavaSource and WebContent.

You need to create your own package or directory inside JavaSource, say, abc, and all Resource files are located inside abc.

Then, in the WebContent directory, the struts-config.xml and tiles-defs.xml are there. And inside the tiles-defs.xml, you can specify the resource files in the master layout by:


Thus, the Struts and Tiles can be referred to the messages inside the resource files.

But, it may with different cases for different IDEs, so, you may need to check with your own IDE setting.

Hope this help.

Nick
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nicholas, it seems you didn't answer the question.

My question is there are two Resource Bundle files in the two modules' struts-config.xml files respectively. The problem right now is it cannot look up the messages at the correct resources bundle file.

How can I fix it?


Thanks
Benson
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is because you did not specify which resource files are going to be used, and the files are not placed in the correct directory.

As my example stated, you can see that, in WSAD, the resource files are NOT necessary to be with the same directory of the struts-config file. We put the struts-config.xml files inside WebContent directory, while we put the resource files inside the JavaSource directory.

In this case, if you need to use the resource files, you need to use Tiles. Did you setup all stuffs correctly according to your IDE setting?

In addition, in the struts-config.xml, you need to have the location of the resource bundle:

This resource points to the JavaSource directory in WSAD.

and the Tiles plug-in definition, if you need:


Have you specified the <message-resources> tag inside your struts-config.xml?

Nick
[ May 20, 2004: Message edited by: Nicholas Cheung ]
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok! Let me make it clear.

There are two struts-config.xml files,

1. struts-co-config.xml
2. strtus-po-config.xml

both of these files are in /WEB-INF/conf folder.

There are also two resource bundle files, ApplicationResources-co.xml, ApplicationResources-po.xml. Both files are in /WEB-INF/classes/com/lcl/cpb/resources folder.

In struts-co-config.xml file,

The configuration is

<message-resource parameters="com.lcl.cpb.resources.ApplicationResources-co" />

In strtus-po-config.xml file,

the configuration is

<message-resource parameters="com.lcl.cpb.resources.ApplicationResources-po" />

I am using Eclipse. But I don't think it is IDE problem. I think it must be the configuration problem that I don't know how to set.


Thanks for your help, Nicholas.


Benson
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


<message-resource parameters="com.lcl.cpb.resources.ApplicationResources-co" />


Is this a typo or the config. really look like this?
The tag name should be message-resources, NOT message-resource
and the attribute should be parameter, NOT parameters.

Nick
[ May 20, 2004: Message edited by: Nicholas Cheung ]
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just typo. No problem. Anyway, the whole thing is like that.


Benson
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is just typo.

Anyway, do you know how to fix it?


Benson
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your modules should not look for the default .properties unless the modules' struts-configs define the default .properties in mess-res.

The problem right now, struts cannot find out the name/value mapping in ApplicationResources-po/co.properties. It only searches in the default file, ApplicationResources.properties.


Could you be more specific about how struts is trying to find them?
Where exactly is your app referencing them?

For any given user session, Struts will only think in one module at a time. If your app has not SwitchActioned to the co module, struts will not use the mess-res defined for the co module.
If the location that references the co.properties can't find it, my first thought is that the session was not SwitchActioned to use the co module.
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok!

scenario :

In struts-co-config.xml, it defines :
<message-resouces key="CO_MESSAGE_KEY" parameter="com.lcl.cpb.resources.ApplicationResourcesCO"/>

In struts-po-config.xml, it defines :
<message-resources key="PO_MESSAGE_KEY" parameter="com.lcl.cpb.resourecs.ApplicationResourcesPO"/>

In web.xml

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/conf/struts-config.xml</param-value>
</init-param>

<init-param>
<param-name>config/co</param-name>
<param-value>/WEB-INF/conf/struts-co-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/po</param-name>
<param-value>/WEB-INF/conf/struts-po-config.xml</param-value>
</init-param>

in the JSP file,

<bean:message bundle="CO_MESSAGE_KEY" key="app.createCustOrder"/>

The error message :

Cannot look up for CO_MESSAGE_KEY.(or similar meaning)

Please help

THanks
Benson
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Geez, what a bad thread -- everybody not understanding everybody. Fun to read, but yikes! Anyhooooo, basically there's a problem with Struts allowing resource bundles to be defined by "child" modules. Define them as part of the default config file and leave them out of the others.

How's that for understanding?
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nathaniel,

Do you think it is struts' bug or somehow there are some tricky things hidden behind that we don't know?

Benson
reply
    Bookmark Topic Watch Topic
  • New Topic