You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Tim Stavenger (JIRA)" <ji...@apache.org> on 2009/03/03 16:54:46 UTC

[jira] Commented: (WW-2802) Unselected multi-select boxes do not post back request parameters, therefore the associated attributes do not get cleared

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

Tim Stavenger commented on WW-2802:
-----------------------------------

The same problem is in the doubleselect.ftl and the optiontransferselect.ftl.

> Unselected multi-select boxes do not post back request parameters, therefore the associated attributes do not get cleared 
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-2802
>                 URL: https://issues.apache.org/struts/browse/WW-2802
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.2
>            Reporter: Tim Stavenger
>             Fix For: 2.1.7
>
>         Attachments: MultiselectInterceptor.java, select.ftl
>
>
> Internet Explorer 7 (and I would assume other browsers) does not post back request parameters for multi-select boxes that have no selections. My understanding is that this is by design -- the HTML spec does not require an unselected muli-select box to be posted back as a request parameter.
> This is akin to the checkbox, where an unchecked checkbox does not get posted back.
> A problem arises when a particular Collection backing a multi-select box needs to be cleared. The user would unselect all values in the multi-select box and submit the page. But since the browser doesn't post any request parameters, Struts leaves the Collection alone. The original values are left alone instead of cleared as desired.
> I propose a similar solution for this problem as is done for the checkbox. A hidden field can be added for every multi-select box that is searched for in an interceptor. If in the interceptor, only the hidden field is found (and therefore the component was left unselected), the interceptor could add a new parameter with its value as an empty array.
> I've attached updated select.ftl and a new MutliselectInterceptor. I apologize in advance if I'm not following protocol... I can't seem to find instructions for that (I'm sure it is out there somewhere...). The interceptor will also need to be added to struts-default.xml and placed in front of the params interceptor. I would suspect that an easy thing to do would be to add it in at the same places where the checkbox interceptor is found.

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