I had limited success with the
private Long[] valueArray;
The problem was that the Interceptor that the conversion interceptor was generating an error when no values were selected. The reason this was happening was due to the fact that instead of returning an empty array or even null, Struts now returns "false" by default. This meant that valueArray[0] == "false" which obviously cannot be converted to a number.
Here's how I overcame the multibox functionality:
JSP Code:
<s:iterator status="rowStatus" value="orderList">
<tr>
<td>
<s:checkbox fieldvalue="%{orderId}" name="valueArray">
</td>
<td>
<s:property value="orderName">
</td>
</tr>
</s:iterator>
Action Code:
private List
public String execute() throws Exception
{
long[] longArray = asLongArraySafe(valueArray);
// Do something with the longArray.
}
// This method will create an array that contains only the numeric values.
public long[] asIntArraySafe(List
{
long[] results = new long[0];
ArrayList
if(list != null && list.size() > 0)
{
for(String valueString : list)
{
try
{
parsedValueList.add(new Long(valueString));
}catch(Exception e){}
}
results = new long[parsedValueList.size()];
int x = 0;
for(Long value : parsedValueList)
{
results[x++] = value.longValue();
}
}
return results;
}