HashMap< String, ArrayList<String> >: Unable to populate the Array List from JSP

View: New views
4 Messages — Rating Filter:   Alert me  

HashMap< String, ArrayList<String> >: Unable to populate the Array List from JSP

by ravi_eze :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

When we had the data structure as: HashMap<String,String> the following jsp fragment was able to populate it:
<s:textfield name="map['key']" />

but the same thing is not working with HashMap<String, ArrayList<Stirng> > when we tried:
<s:textfield name="mapOfList['key']".

We also tried instantiating the object in the action class constructor:
mapOfList = new HashMap<... >();
mapOfList.put("key", new ArrayList());

still no luck.... Using POJOs instead of hashmap would not fit to my requirements.

any help ???

cheers,
ravi

Re: HashMap< String, ArrayList<String> >: Unable to populate the Array List from JSP

by Wes Wannemacher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Assuming you have appropriate getters and setters on your action for the
HashMap of ArrayLists, you should be able to set them using indexing
like this -

<s:textfield name="mapOfList.key[i]" />
or
<s:textfield name="mapOfList['key'][i]" />

(where "i" is an integer representing the index where you want the
String set)

http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/indexing.html

-Wes


On Tue, 2008-04-29 at 21:54 -0700, ravi_eze wrote:

> hi,
>
> When we had the data structure as: HashMap<String,String> the following jsp
> fragment was able to populate it:
> <s:textfield name="map['key']" />
>
> but the same thing is not working with HashMap<String, ArrayList<Stirng> >
> when we tried:
> <s:textfield name="mapOfList['key']".
>
> We also tried instantiating the object in the action class constructor:
> mapOfList = new HashMap<... >();
> mapOfList.put("key", new ArrayList());
>
> still no luck.... Using POJOs instead of hashmap would not fit to my
> requirements.
>
> any help ???
>
> cheers,
> ravi


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: HashMap< String, ArrayList<String> >: Unable to populate the Array List from JSP

by ravi_eze :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

Thanks for he help. i am using as follows:

< s:checkboxlist name="mapOfList['key']" />

I see that this is not working and the mapOfList is not getting populated at all. I tried out StrutsTypeConverter... then only convertToString() method is being called. Any ideas as how to go with this issue???

sorry for the wrong example prev.

regards,
ravi

HashMap< String, ArrayList<String> >: Unable to populate the Array List from JSP

by ravi_eze :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Team,

any help??? now i configured the validation, workflow interceptors in my xml file. I see an error for this field variable.

I tried configuring the converter... but as always its also failing...

< actionclass>-conversion.properties:
mapOfList=com.company.CustomMapConverter
Element_mapOfList=java.util.ArrayList
Key_mapOfList=java.lang.string

I see a weird behavior: only the convertToString() function being called...

had any body fixed such issues???

please help

cheers,
ravi