struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Belingueres <belingue...@gmail.com>
Subject Re: Param Interceptor - Unable to save the data for Map of Lists
Date Thu, 07 Jan 2010 12:33:02 GMT
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 <saty.prasad@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


Mime
View raw message