• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
J Livermore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic