struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Lindholm (JIRA)" <j...@apache.org>
Subject [jira] Commented: (WW-2339) empty checkbox list results in "Invalid field value for field" error when using Collection or array containing non-boolean values.
Date Tue, 01 Apr 2008 21:23:58 GMT

    [ https://issues.apache.org/struts/browse/WW-2339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43567#action_43567
] 

Greg Lindholm commented on WW-2339:
-----------------------------------

I'm having this problem as well. 

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}" />
</s:iterator>

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 com.xyz.struts.MyAction:
Error setting expression 'accountIds' with value 'false'


Did a little debugging and I think the problem is in the CheckboxInterceptor.

It's creating a new param to handle the not checked case, this isn't correct if we have an
array of checkboxes.

I think it needs to check if the parameter "__checkbox_xxx" value is an array with size >
1 it should not create the new 'false' param.

If I can make this work I will submit the patch.

> empty checkbox list results in "Invalid field value for field" error when using Collection
or array containing non-boolean values.
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-2339
>                 URL: https://issues.apache.org/struts/browse/WW-2339
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.0.11
>         Environment: Tomcat 6, XWork 2.0.4
>            Reporter: Mike Calmus
>             Fix For: Future
>
>
> I have an action that has a "selectedPageItems" element of type List<Long>. Using
a JSp containing several checkboxes with value attributes of type Long, I receive an "Invalid
field value for field" error when no items are selected.
> The CheckboxInterceptor class has the following code block:
>                 // is this checkbox checked/submitted?
>                 if (!parameters.containsKey(name)) {
>                     // if not, let's be sure to default the value to false
>                     newParams.put(name, uncheckedValue);
>                 }
> This causes a single boolean (or String) value to be added to the parameter list when
no values are selected. This works fine if the Collection holds String or boolean values.
However, in my situation the value can not be assigned to the Collection, giving the error.

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


Mime
View raw message