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/12/16 05:21:37 UTC

[jira] Resolved: (WW-2763) Prepopulation of checkboxlist fails when using listValue and listKey in FreeMarker tag

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

Musachy Barroso resolved WW-2763.
---------------------------------

    Resolution: Not A Problem

By setting listKey,  struts will compare the value of the keys (in this case string), with the list of selected objects, in this case enums, which will never match, hence none will be selected.

> Prepopulation of checkboxlist fails when using listValue and listKey in FreeMarker tag
> --------------------------------------------------------------------------------------
>
>                 Key: WW-2763
>                 URL: https://issues.apache.org/struts/browse/WW-2763
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.0.11.2
>         Environment: Struts 2.0.11.2, Vista, Java 1.6.007, FreeMarker
>            Reporter: Stephan Schroeder
>            Priority: Minor
>             Fix For: 2.1.3
>
>
> This usage of the checkboxlistworks
> <@s.checkboxlist label="Attribute" name="trainingAttributes"  list="%{@domainobjects.util.TrainingAttribute@values()}"/>
> domainobjects.util.TrainingAttribute is an enum.
> trainingAttributes is an array of type TrainingAttribute with a subset of TrainingAttribute.values().
> Of course this displays the Java-Names of the enum-Instances therefore i added the two methods for the key and the name:
> public enum TrainingAttribute
> {
>   ADVANCED,BEGINNER,CHILDREN,WEAPON;
>   
>   public String getKey()
>   {
>     return toString();
>   }
>   
>   public String getName()
>   {
>     switch( this ) {
>       case ADVANCED: return "Fortgeschrittene";
>       case BEGINNER: return "Anfänger";
>       case CHILDREN: return "Kinder";
>       case WEAPON:   return "Waffen";
>     }
>     throw new RuntimeException( "unknown enum:"+getClass().getName() );
>   }
> }
> Now i added the listValue- and listKey-parameter:
> <@s.checkboxlist label="Attribute" name="trainingAttributes"  list="%{@domainobjects.util.TrainingAttribute@values()}" listValue="name" listKey="key"/>
> but no checkbox is checked. Using @s.select with the multiple=true option doesn't prepopulate either.

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