tags:

views:

46

answers:

1

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>
A: 

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.properties file 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

Element-lastEntities=com.yourcompany.WhateverObject

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.

Shawn D.
Hi, I am using JDK1.4. so i can't use generics. Where do i need to declare it?do i need to use something like conversion. If so how to use it?
Jothi