Lukasz Lenart created WW-5847:
---------------------------------

             Summary: doubleselect: preselection in the second list with 
doubleMultiple has never worked
                 Key: WW-5847
                 URL: https://issues.apache.org/jira/browse/WW-5847
             Project: Struts 2
          Issue Type: Bug
          Components: Core Tags
            Reporter: Lukasz Lenart
             Fix For: 7.5.0, 6.13.0


{{doubleselect.ftl}} in the simple theme preselects the second list's current 
value inside the generated script. The single-value branch writes 
{{doubleNameValue}} as a quoted string literal. The branch taken when 
{{doubleMultiple}} is set writes it unquoted, as the loop bound and in the 
comparison, so a plain {{String}} becomes a bare identifier and the script 
fails on page load; a {{Collection}} renders through {{toString}} with the same 
result, and a {{String[]}} fails the template render. The branch is also chosen 
by an existence check, so {{doubleMultiple="false"}} takes it too.

Present since WW-2809 (2.1.8). {{support/struts-6-x-x}} carries the identical 
template. The xhtml theme includes the simple template; the html5 theme renders 
a placeholder for this tag and is unaffected.

h2. Proposed change
* Normalise {{doubleNameValue}} in {{DoubleListUIBean}} to a list (from a 
{{String}}, a {{Collection}} or an array) and emit it in the script as an array 
of quoted, JS-escaped string literals, as the single-value branch already does 
for one value.
* Select the branch on the boolean value of {{doubleMultiple}}, not on its 
presence.

h2. Compatibility

Preselecting several values in the second list works. The single-value path 
renders as before.

h2. Tests
* A {{String}}, a {{Collection}} and a {{String[]}} under 
{{doubleMultiple="true"}} each render a quoted list and preselect the matching 
options.
* {{doubleMultiple="false"}} renders the single-value path.
* The existing DoubleSelect fixtures keep passing.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to