You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by satyanarayana katta <sa...@gmail.com> on 2010/01/07 07:57:20 UTC
Param Interceptor - Unable to save the data for Map of Lists
Hi,
Struts Version - 2.1.7
We have an issue with the Map<String, List<Object>>. Here is the
scenario, we are displaying the data from the List on the UI as the
text fields. When a user changes and submits the form, the form data
has to be saved.
We are able to display the data from the List onto the UI. When the
form is submitted, the Map is coming back as null in the action class.
<s:iterator value="textMap" status="iterStatus">
<s:iterator value="value" status="iterStatus1">
<s:textfield name="textMap['%{key}']['%{#iterStatus1.index}'].name"
value="%{name}"/>
</s:iterator>
</s:iterator>
I am also attaching the source code
SampleAction.java
Sample.java (Pojo representing the Object in the list)
struts.xml
struts
sample.jsp.
Please help.
Rgds,
Satya
Re: Param Interceptor - Unable to save the data for Map of Lists
Posted by Gabriel Belingueres <be...@gmail.com>.
You didn't attach the action source code, but I guess you are not
instantiating the Map before the ParameterInterceptor is executed. I
can think of 3 choices to do that:
1) instantiate the Map in the same place you declare the instance variable:
Map<String, List<Object> textMap = new HashMap<String, List<Object>();
2) instantiate the Map inside a prepare method (the action must
implement Preparable interface)
public void prepare() {
textMap = new HashMap<String, List<Object>();
}
3) get the (not null) instance from another place inside in the Map
getter & setter, for example, from session scope:
public Map<String, List<Object> getTextMap() {
return (Map<String, List<Object>) sessionMap.get("themap");
}
HTH
2010/1/7 satyanarayana katta <sa...@gmail.com>:
> Hi,
>
> Struts Version - 2.1.7
>
> We have an issue with the Map<String, List<Object>>. Here is the
> scenario, we are displaying the data from the List on the UI as the
> text fields. When a user changes and submits the form, the form data
> has to be saved.
>
> We are able to display the data from the List onto the UI. When the
> form is submitted, the Map is coming back as null in the action class.
>
> <s:iterator value="textMap" status="iterStatus">
> <s:iterator value="value" status="iterStatus1">
> <s:textfield name="textMap['%{key}']['%{#iterStatus1.index}'].name"
> value="%{name}"/>
> </s:iterator>
> </s:iterator>
>
> I am also attaching the source code
>
> SampleAction.java
> Sample.java (Pojo representing the Object in the list)
> struts.xml
> struts
> sample.jsp.
>
> Please help.
>
> Rgds,
>
> Satya
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org