This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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...
Joined: Mar 13, 2010
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.
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.
Joined: Mar 13, 2010
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.
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
Joined: Apr 01, 2009
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.