Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The forward action isn't in the same package as your action--it's an XW2/S2 class.
 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this, on that page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic