struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Lindholm (JIRA)" <>
Subject [jira] Commented: (WW-2564) Type Conversion of List<Integer> not working when list is empty.
Date Tue, 01 Apr 2008 18:23:58 GMT


Greg Lindholm commented on WW-2564:

I'm having this problem as well. (I don't think Ivan's solution will work in the general case.)

I'm displaying a list of checkboxes for account names:

<s:iterator value="accountInfoList" status="accountInfoStatus">
<s:checkbox name="accountIds" label="%{name}" value="%{enabled}" fieldValue="%{id}" />

It then sets the array of selected account ids.

public void setAccountIds(Long[] accountIds)...

This works fine as long as at least one checkbox was selected. 
If no checkboxes are selected then I get:

ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor:204 - ParametersInterceptor
- [setParameters]: Unexpected Exception caught setting 'accountIds' on 'class
Error setting expression 'accountIds' with value 'false'

It appears that if none are selected it doesn't realize it's dealing with an array so attempts
to set it as a simple boolean 'false'.
I attempted to work-around this by adding overload method "public void setAccountIds(Boolean
none)...". This didn't work, got the same error.

> Type Conversion of List<Integer> not working when list is empty.
> ----------------------------------------------------------------
>                 Key: WW-2564
>                 URL:
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions:
>         Environment: Windows XP
>            Reporter: Ivan Rei
> When using a object of type List<Integer>, and that object comes empty from the
JSP, you get a conversion error. Eg. Have 2 lists of checkboxes on the JSP. One is a List<String>
and the other is List<Integer>, if I don't select any of the checkboxes of either type,
I get a validation error (xwork.default.invalid.fieldvalue) on the integer list only. If I
remove the integer list from the JSP, I get to the action.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message