I have assigned Hahmap to the dropdowns.. each dropdown laues will be set into hashmap. when i try to get these values i am geeting values as string array instead of one object.so, i am not able to repopulate values if validation fails.
below is the code i am using to populate the values.
<s:iterator value="#actComments.lstEntities">
<tr>
<td width="15%" align="left"><s:textfield name="propType"
readonly="true" value="%{#attr.propertyTypeName}"
cssStyle="width:80px;font-size:11px;" /></td>
<td width="85%" align="left"><s:select
name="hmMapComment[%{#attr.propertyTypeId}]"
cssStyle="font-size:11px;width:457px;margin-bottom:3px"
headerKey="0" headerValue="-- Select Comment --" list="comments"
listKey="commentId" listValue="commentText" /></td>
</tr>
</s:iterator>
In your getter declaration, do you have the HashMap declared to contain the appropriate types (i.e. HashMap< String, Integer >), or do you just have it as ‘HashMap’? It’s my understanding that if you don’t specify the types in the getter signature, the returned objects will be evaluated as strings.
Edit: if you’re using below JDK 1.5, you can make a
'ClassName'-conversion.propertiesfile in your classpath for the appropriate action class (or maybe for the actComments, not sure). That’ll allow you to tell the type conversion code what type it is.Add a line like
I’m not sure how you do subelements, whether you’d have to specify Element-actComments.lstEntities or something else. I’d try fiddling with that.