[
https://issues.apache.org/struts/browse/WW-2802?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tim Stavenger updated WW-2802:
------------------------------
Attachment: MultiselectInterceptorTest.java
Here's a test case that I copied off of the CheckboxInterceptorTest. It has
been modified for the MultiselectInterceptor.
Honestly, I wasn't able to verify the test passes as I kept getting the
following error:
SEVERE: [16:08.132] ********** FATAL ERROR STARTING UP STRUTS-SPRING
INTEGRATION **********
Looks like the Spring listener was not configured for your web app!
Nothing will work until WebApplicationContextUtils returns a valid
ApplicationContext.
You might need to add the following to web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
SEVERE: [16:08.148] Dispatcher initialization failed
>From my web searches, it looks like people see this if the Spring plug-in is
>included but they aren't really using Spring. In this case, the Spring plug-in
>wasn't included, but I had to include Spring and Spring Mock because of
>dependencies in the StrutsTestCase super class. I must have been doing
>something wrong, so if you can help me get it running, I'll be sure it
>passes... This is at least a starting point for you.
> 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.8
>
> Attachments: checkboxlist.ftl, doubleselect.ftl,
> MultiselectInterceptor.java, MultiselectInterceptorTest.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.