This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Issue with localization: Messages not picked up from properties file for forward actions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 Issue with localization: Messages not picked up from properties file for forward actions." Watch "Struts2 Issue with localization: Messages not picked up from properties file for forward actions." New topic
Author

Struts2 Issue with localization: Messages not picked up from properties file for forward actions.

kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
Newbie question here: I am sure I have missed something but I have pored through the Struts localization tutorial http://struts.apache.org/2.x/docs/localization.html but I can not find a resolution.


In my package structure, I have package.properties file with the following
key value pair:

In my simple login page: the form elements are defined with a key look up..


In my struts.xml, I have defined the action mapping. The first action is a forward action
to the login page.



When I try to load the login_input action, I don't see the messages picked up from package.properties. But when I submit the form and it fails validation, it is picked up from the resource bundle. What is it that I have to do in order to have the messages picked up from resource bundle for a forward action?

Any advice would be useful.

Thanks,

Kartik

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The forward action isn't in the same package as your action--it's an XW2/S2 class.
kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
David Newton wrote:The forward action isn't in the same package as your action--it's an XW2/S2 class.


Hi David,

I don't know what that means. Does that mean the forward action does not know where to pick up the messages?

Kartik
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I18N messages are placed in package hierarchy: if your actions are in com.foo.bar, and that's where the package.properties file is, an action from com.opensymphony.xwork2 or org.apache.struts2 wouldn't have access to the same resources. You'll need to either change the package structure, use a locally-packaged forward action, set up a default resource file, or etc.
kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
Hi David,

How do you configure global resources? I looked at this link and I did not find anything useful.

http://struts.apache.org/2.0.14/docs/localization.html
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

See this, on that page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Issue with localization: Messages not picked up from properties file for forward actions.
 
Similar Threads
"No configuration found for the specified action"
Struts 2 - i18n Chinese localization issue
Struts 2: Localization not working
How to change the default label style in Struts2?
NullPointerException at the SessionFactory create line.