• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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

 
Author
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
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this, on that page.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic