This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 label tag -  key attribute is being replaced with actual value? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 label tag -  key attribute is being replaced with actual value?" Watch "Struts2 label tag -  key attribute is being replaced with actual value?" New topic
Author

Struts2 label tag - key attribute is being replaced with actual value?

J Livermore
Greenhorn

Joined: Nov 22, 2011
Posts: 5
I am using the simple theme to avoid table structure in my form. And when I use the Struts2 label tag in conjunction with a select tag linking the two by the key attribute , my label is changing when I set the select drop down in the form? The Form elements look like this:

<s:label key="country" />
<s:select name="country" key="country" id="country" cssClass="styled" headerKey=""
headerValue="Select From" value="%{country}"
list="{'Afghanistan','Albania','Algeria'}" required="true"
cssErrorClass="fv_error"/>

When the page renders, the label tag is generated with the correct value of 'COUNTRY', but when I select a country value from the select drop down, and then submit the form, other form errors are thrown because of missing values - validation occurs properly - and then the label changes to the country selected?

I need the label to remain the same and not change to the selected drop down value?
J Livermore
Greenhorn

Joined: Nov 22, 2011
Posts: 5
The issue was the key name in the resource file, by qualifying it further by changing the key from country to label.country. So then in the JSP file, the label now looks like:

<s:label key="label.country" />
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 label tag - key attribute is being replaced with actual value?
 
Similar Threads
How to use the select tag - Struts2
populate items using struts2 <s:select>
Select Tag error in struts2
struts2 select and js
Struts2: problem with select tag