[ 
https://issues.apache.org/jira/browse/WW-5847?focusedWorklogId=1053292&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1053292
 ]

ASF GitHub Bot logged work on WW-5847:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Nov/26 19:43
            Start Date: 07/Nov/26 19:43
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #2127:
URL: https://github.com/apache/struts/pull/2127

   Fixes [WW-5847](https://issues.apache.org/jira/browse/WW-5847)
   
   Cherry-pick of #2126 onto `support/struts-6-x-x`. The only differences are 
the `parameters.` template prefix and the 6.x imports.
   
   With `doubleMultiple` set, the simple theme's `doubleselect.ftl` 
interpolated the bound value of the second list into the generated script 
unquoted. A plain `String` became a bare identifier and the script failed on 
page load, a `Collection` rendered through `toString` with the same result, and 
a `String[]` failed the template render. The branch was also chosen by the 
attribute's presence, so `doubleMultiple="false"` took it too.
   
   ## Change
   
   - `DoubleListUIBean` resolves the second list's value once and also exposes 
it as a list of strings (`doubleNameValues`), normalised from a `String`, a 
`Collection` or an array through `MakeIterator`.
   - The template emits that list as `var <id>Selected = [...]`, an array of 
quoted, JS-escaped string literals written the same way the single-value branch 
and the option values already are, and the preselect loop compares against it.
   - The branch is selected by the boolean value of `doubleMultiple`.
   
   ## Compatibility
   
   Preselecting several values in the second list works. The single-value path 
renders exactly as before; the existing `DoubleSelect-*` fixtures are unchanged.
   
   ## Tests
   
   `DoubleSelectMultipleTest` covers a `Collection` (full fixture 
`DoubleSelect-7.txt`), a `String`, a `String[]`, values containing quotes, 
backslashes and a closing script tag rendering as string literals, and 
`doubleMultiple="false"` taking the single-value path. Full `core` suite green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1053292)
    Time Spent: 0.5h  (was: 20m)

> 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
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 6.13.0, 7.5.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {{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