Multi-select boxes do not post back a request parameters, therefore the
associated attributes to not get cleared
-----------------------------------------------------------------------------------------------------------------
Key: WW-2802
URL: https://issues.apache.org/struts/browse/WW-2802
Project: Struts 2
Issue Type: Bug
Affects Versions: 2.1.2
Reporter: Tim Stavenger
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.