struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Abrams <donabr...@gmail.com>
Subject Values saving with brackets when setting values inside of lists of lists?
Date Thu, 04 Mar 2010 14:02:10 GMT
So I'm trying to save tables in struts.

I'm hitting a strange error when setting values of Lists of Lists, which
causes any value saved to be contained in brackets.  The params interceptor
doesn't log these brackets so its probably an error in the setting function
(OGNL?).  I couldn't find this behavior documented anywhere.  I know
Multi-dimensional arrays work fine (String[][] instead of
List<List<String>>).  Anyone know a workaround for lists of lists (example
below)?

Also, I couldn't find a way to make struts form tags work inside iterators.
 Does anyone know of a plugin or extension that supports this?  I have a
workaround, but its slower to duplicate the struts checkbox and multiselect
functionality by hand.

Thanks,
Don

#table.jsp
<form action="someAction">
<table>
<s:iterator value="listOfLists" status="rowStatus">
<tr>
  <s:iterator status="columnStatus">
    <td>
    <input type="text" name="listOfLists[<s:property
value="#rowStatus.index"/>][<s:property value="#columnStatus.index"/>]"
value="<s:property/>">
    </td>
  </s:iterator>
</tr>
</s:iterator>
</table>
</form>

#action
public class SomeAction {
   private List<List<String>> listOfLists;
   public List<List<String>> getListOfLists() {
      return table;
   }
   public SomeAction() {
      if (listOfLists == null) {
         listOfLists = new ArrayList<List<String>>();
         for (int i = 0;i<10;i++) {
            listOfLists.add(new ArrayList<String>());
            for (int j = 0;j<10;j++)
               listOfLists.get(i).add("(" + i + "," + j + ")");
         }
      }
   }
}

#spring
<bean id="someAction" class="SomeAction" scope="singleton"/>

#struts
<action name="someAction" class="someAction">
   <result>table.jsp</result>
</action>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message