Ping Sudsy: SOLVED: Locale/Struts problem

S

Steve Sobol

The docs need to be cleared up a little bit, I think - I can't find anything on
Apache's Struts site that says the message resource file has to be in
WEB-INF/classes, but it does. I finally realized that the problem I was having
was NOT a locale problem when I looked and realized that according to my
resource file, errors are supposed to be wrapped inside <UL></UL> tags and they
weren't.

I'm going to go look at the Struts docs again and see if maybe I missed the
portion where it says the resources have to be under WEB-INF/classes.
 
S

Sudsy

Steve said:
The docs need to be cleared up a little bit, I think - I can't find
anything on Apache's Struts site that says the message resource file has
to be in WEB-INF/classes, but it does. I finally realized that the
problem I was having was NOT a locale problem when I looked and realized
that according to my resource file, errors are supposed to be wrapped
inside <UL></UL> tags and they weren't.

I'm going to go look at the Struts docs again and see if maybe I missed
the portion where it says the resources have to be under WEB-INF/classes.

I don't know that it's expressed clearly in the documentation but it
makes sense when you think about it. Have you ever seen examples like
this?
<message-resources null="false" parameter="net.sudsy.messages"/>
That's would twig you to the fact that the parameter is actually a
class, hence should be found in the WEB-INF/classes heirarchy.
Take a look at the struts-config DTD and you'll note that, in the
message-resources element, there is an attribute named factory with
a defaultvalue of org.apache.struts.util.PropertyManagerResourceFactory.
Navigating to the appropriate page in the javadocs reveals this gem:
"The configuration paramter (sic) for such instances is the base
Java package name of the resources entries from which our keys and
values will be loaded."
The key there is "base Java package name". Again, it should lead
you to the conclusion that the properties files have to be stored
in the WEB-INF/classes heirarchy.
But then if you'd dropped the coin to purchase the excellent
reference "Programming Jakarta Struts" by Chuck Cavaness (ISBN
0-596-00328-5) the you'd have found the information on page 295,
to wit:
"The resource bundle needs to be placed in a location where it
can be found and loaded. This means that the same class loader
that loads the web application must also be able to locate and
load the resource bundle. For web applications, the appropriate
location is the WEB-INF/classes directory.
If you provide a package name for the resource bundle, it must
reside in the correct package as well. For example, if you name
your resource bundle com.oreilly.struts.StorefrontResources.properties,
you must place it into the WEB-INF/classes/com/oreilly/struts
directory."
It's a super book, IMHO. I just wish I'd bought it earlier; it
would have saved a lot of headaches.
 
S

Steve Sobol

Sudsy said:
I don't know that it's expressed clearly in the documentation but it
makes sense when you think about it. Have you ever seen examples like
this?
<message-resources null="false" parameter="net.sudsy.messages"/>

Yes, I've seen that. Makes sense now that I think about it.
But then if you'd dropped the coin to purchase the excellent
reference "Programming Jakarta Struts" by Chuck Cavaness (ISBN
0-596-00328-5) the you'd have found the information on page 295,
to wit:
[snip]

It's a super book, IMHO. I just wish I'd bought it earlier; it
would have saved a lot of headaches.

Noted. I'll have to go get it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top