aspose file tools*
The moose likes Struts and the fly likes Internationalization issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Internationalization issue" Watch "Internationalization issue" New topic
Author

Internationalization issue

Johan Berg
Greenhorn

Joined: Mar 13, 2010
Posts: 3
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

Joined: Mar 02, 2005
Posts: 443
    
    1

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

Joined: Mar 13, 2010
Posts: 3
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

Joined: Mar 02, 2005
Posts: 443
    
    1

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

Joined: Mar 13, 2010
Posts: 3
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

Joined: Apr 01, 2009
Posts: 642
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

Joined: Apr 01, 2009
Posts: 642
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internationalization issue
 
Similar Threads
Jtable showing last record only
speech
ognl.OgnlException: target is null for setProperty(null, "preventCache", [Ljava.lang.String;@6dc5f0b
Getting Last Record in Jtable
Weblogic 8.1 Pool Connection Error