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

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

checkboxlist.ftl falls victim to this problem too... the file is attached.

I changed it in both the simple theme and my custom theme, which I created off 
of the Struts css theme (if I remember correctly). So the extra hidden field 
may need to be added in more than one place (in themes other than simple)!

> 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: checkboxlist.ftl, doubleselect.ftl, 
> MultiselectInterceptor.java, optiontransferselect.ftl, select.ftl, 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.

Reply via email to