Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Internationalization issue

 
Johan Berg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I have a little issue I am trying to solve. Probably missed some info on struts documentation, but couldn't find any to solve this.

Here is my exception:


I get this when trying to submit the form to a modeldriven action (default-stack and validation). The jsp looks like this:


property.username is located at User.properties file.

I can post more code and info if needed.

 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I do think that Struts would be able to find the .properties file you have mentioned. By default it looks for a package.properties (maybe also a Application Resource.properties) in the WEB-INF/classes folder of the webapp. It should work if you do likewise...

Cheers,
Raj.
 
Johan Berg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raj!

Yes it do find the properties file and internationalization works, but when submitting the form the internationalization somehow gives that exception which I can not understand what it really means.
It looks to me that OGNL trying to find for a property "property.username" but it should be just Username (property.username=Username). The labeling works but the name attribute seems to try to
set "property.username" which is wrong.

If I remove the internationalization it works and I could do that, but I know I would need it for future use.

Hope you understood me.

Cheers,
Johan
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gotcha!

I think without a name attribute for the s:textfield Struts tries to call a getter on the key to fetch the value for the field for initial display. If you give a name attribute this ought to be rectified.

I'm speaking of something like:-


Where 'username' in a property of type String in the cirresponding Action class.

Cheers,
Raj.
 
Johan Berg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so the standard attributes overrides key attribute. I also noticed this way is better for me, because it would otherwise look for a for "username" setter-method in swedish in my action/domain.

Anyway, thanks for the help!

Cheers,
Johan
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but one of the points of using the key attribute is that you no longer need the name attribute, as the key value will be used both for the lookup in the resource bundle and to locate the property on the Value Stack.

However, for that to work, the key value must match the property name in the model. I don't think that's the case here, unless you have a property named "property.username"

 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johan Berg wrote:I also noticed this way is better for me, because it would otherwise look for a for "username" setter-method in swedish in my action/domain.


It should look for the property based on the value of the key attribute, not based on the localized label you have assigned to that key in the resource bundle. If the property in your model is named bletch, then the key value should be bletch and you should have an entry in the resource bundle with a key of bletch which provides a localized label for the property.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic