You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Musachy Barroso (JIRA)" <ji...@apache.org> on 2008/11/19 20:30:36 UTC

[jira] Updated: (WW-2156) double doubleselect without ids and name cause selection error

     [ https://issues.apache.org/struts/browse/WW-2156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso updated WW-2156:
--------------------------------

    Fix Version/s:     (was: 2.1.3)
                   Future

moving to "future", pending patch

> double doubleselect without ids and name cause selection error
> --------------------------------------------------------------
>
>                 Key: WW-2156
>                 URL: https://issues.apache.org/struts/browse/WW-2156
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Yinghao LI
>             Fix For: Future
>
>
> When there are two doubleselect without id attributes, the selection of the first's first select while change the options of the second's second select.
> The problem is :
> the name and the id of doubleselect aren't required attributes. When they are both absent, the value of name and id is the form_name concat with "_". When we use two or more doubleselect,  struts will create same variables and function in javascript with the doubleselect.ftl in the simple template.
> Personnally, i think the id of doubleselect should use the doubleName's value when there is neither id attribute nor name attribute.
> <script type="text/javascript">
> <#assign itemCount = startCount/>
>     var ${parameters.id}Group = new Array(${parameters.listSize} + ${startCount});
>     for (i = 0; i < (${parameters.listSize} + ${startCount}); i++)
>     ${parameters.id}Group[i] = new Array();
> <@s.iterator value="parameters.list">
>     <#if parameters.listKey?exists>
>         <#assign itemKey = stack.findValue(parameters.listKey)/>
>     <#else>
>         <#assign itemKey = stack.findValue('top')/>
>     </#if>
>     <#if parameters.listValue?exists>
>         <#assign itemValue = stack.findString(parameters.listValue)/>
>     <#else>
>         <#assign itemValue = stack.findString('top')/>
>     </#if>
>     <#assign doubleItemCount = 0/>
>     <@s.iterator value="${parameters.doubleList}">
>         <#if parameters.doubleListKey?exists>
>             <#assign doubleItemKey = stack.findValue(parameters.doubleListKey)/>
>         <#else>
>             <#assign doubleItemKey = stack.findValue('top')/>
>         </#if>
>         <#assign doubleItemKeyStr = doubleItemKey.toString() />
>         <#if parameters.doubleListValue?exists>
>             <#assign doubleItemValue = stack.findString(parameters.doubleListValue)/>
>         <#else>
>             <#assign doubleItemValue = stack.findString('top')/>
>         </#if>
>     ${parameters.id}Group[${itemCount}][${doubleItemCount}] = new Option("${doubleItemValue}", "${doubleItemKeyStr}");
>         <#assign doubleItemCount = doubleItemCount + 1/>
>     </...@s.iterator>
>     <#assign itemCount = itemCount + 1/>
> </...@s.iterator>
>     var ${parameters.id}Temp = document.${parameters.formName}.${parameters.doubleId};
> <#assign itemCount = startCount/>
> <#assign redirectTo = 0/>
> <@s.iterator value="parameters.list">
>     <#if parameters.listKey?exists>
>         <#assign itemKey = stack.findValue(parameters.listKey)/>
>     <#else>
>         <#assign itemKey = stack.findValue('top')/>
>     </#if>
>     <#if tag.contains(parameters.nameValue, itemKey)>
>         <#assign redirectTo = itemCount/>
>     </#if>
>     <#assign itemCount = itemCount + 1/>
> </...@s.iterator>
>     ${parameters.id}Redirect(${redirectTo});
>     function ${parameters.id}Redirect(x) {
>     	var selected = false;
>         for (m = ${parameters.id}Temp.options.length - 1; m >= 0; m--) {
>             ${parameters.id}Temp.options[m] = null;
>         }
>         for (i = 0; i < ${parameters.id}Group[x].length; i++) {
>             ${parameters.id}Temp.options[i] = new Option(${parameters.id}Group[x][i].text, ${parameters.id}Group[x][i].value);
>             <#if parameters.doubleNameValue?exists>
>             	if (${parameters.id}Temp.options[i].value == '${parameters.doubleNameValue}') {
>             		${parameters.id}Temp.options[i].selected = true;
>             		selected = true;
>             	}
>             </#if>
>         }
>         if ((${parameters.id}Temp.options.length > 0) && (! selected)) {
>            	${parameters.id}Temp.options[0].selected = true;
>         }
>     }
> </script>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.