You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Robert-Jan Westerhof (JIRA)" <ji...@apache.org> on 2007/10/09 11:10:37 UTC

[jira] Created: (WW-2238) checkboxlist labels and values mixed up

checkboxlist labels and values mixed up
---------------------------------------

                 Key: WW-2238
                 URL: https://issues.apache.org/struts/browse/WW-2238
             Project: Struts 2
          Issue Type: Bug
          Components: Views
    Affects Versions: 2.0.9
            Reporter: Robert-Jan Westerhof
            Priority: Minor


The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:

...
        <#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 itemKeyStr=itemKey.toString() />
<input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
...
/>
<label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
...

I believe this should read something like

...
        <#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>
        <#if parameters.label?exists>
            <#assign itemLabel = stack.findString(parameters.label)/>
        <#else>
            <#assign itemLabel = stack.findString('top')/>
        </#if>
<input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
...
/>
<label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
...

Bug priority set to minor, as there is an easy workaround by defining a custom template...


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


[jira] Commented: (WW-2238) checkboxlist labels and values mixed up

Posted by "Robert-Jan Westerhof (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44187#action_44187 ] 

Robert-Jan Westerhof commented on WW-2238:
------------------------------------------

Actually, when treated the same as listKey and listValue (i.e. retrieving the label via stack.findValue(parameters.label)), the label is no more constant than the listKey and listValue are. Personally, I use a list of objects that have 3 attributes, a key, a value and a label, thereby allowing the set of labels to be different from the set of values (if you so choose). It does make sense to default back to the listValue though, iso "top".





> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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


[jira] Reopened: (WW-2238) checkboxlist labels and values mixed up

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes reopened WW-2238:
------------------------------


Upon more thought I believe that the label attribute should be removed from this tag. It does not make sense to apply the same label to a list of checkboxes.

Anyone know how to remove attributes for a tag that is an extension of other classes? The @StrutsTagAttribute annotation for the label attribute is on the UIBean class that the CheckBoxList class ultimately extends from.

> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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


[jira] Updated: (WW-2238) checkboxlist labels and values mixed up

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Don Brown updated WW-2238:
--------------------------

    Fix Version/s:     (was: 2.1.4)
                   2.1.3

> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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


[jira] Commented: (WW-2238) checkboxlist labels and values mixed up

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44438#action_44438 ] 

Musachy Barroso commented on WW-2238:
-------------------------------------

Is the final resolution to hide the attribute? If so, what you need to do is

1. overwrite the setter method in the tag (child tag)
2. annotate the method with @StrutsTagSkipInheritance

> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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


[jira] Resolved: (WW-2238) checkboxlist labels and values mixed up

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-2238.
---------------------------------

    Resolution: Fixed

Closing this, if the tag should be removed (which I am not sure about), see my comment on how to do that.

> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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


[jira] Resolved: (WW-2238) checkboxlist labels and values mixed up

Posted by "James Holmes (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-2238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

James Holmes resolved WW-2238.
------------------------------

    Resolution: Fixed

Fixed in SVN revision 667876.

Note that I implemented this slightly different than you proposed.  The old behavior was putting the checkbox's value as the label and will continue to do that unless the label attribute is specified. The problem with using a label attribute with this tag is that say you have 5 items in a list, all 5 would get the same label. I'm not sure what purpose that would serve, but the template will now allow you to do that if you so desire.

> checkboxlist labels and values mixed up
> ---------------------------------------
>
>                 Key: WW-2238
>                 URL: https://issues.apache.org/struts/browse/WW-2238
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.0.9
>            Reporter: Robert-Jan Westerhof
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> The checkboxlist.ftl that ships with struts2 2.0.9 uses the listValue attribute to populate the labels. The listKey is used as the checkbox values. The label attribute is not used at all in the template. 
> The template as shipped in the template/simple directory in the struts2-core-2.0.9.jar contains the following:
> ...
>         <#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 itemKeyStr=itemKey.toString() />
> <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
> ...
> I believe this should read something like
> ...
>         <#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>
>         <#if parameters.label?exists>
>             <#assign itemLabel = stack.findString(parameters.label)/>
>         <#else>
>             <#assign itemLabel = stack.findString('top')/>
>         </#if>
> <input type="checkbox" name="${parameters.name?html}" value="${itemValue?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
> ...
> />
> <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemLabel?html}</label>
> ...
> Bug priority set to minor, as there is an easy workaround by defining a custom template...

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