[ 
https://issues.apache.org/struts/browse/WW-1601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_39925
 ] 

Laurie Harper commented on WW-1601:
-----------------------------------

There's a fairly easy work--around, submitted on the user list by Stuart 
Piltch: explicitly set the value of the s:select component by calling 
toString() on the non-string value. For example:

    <s:select name="rate" list="rateList" listKey="id" listValue="name"
        value="rate.id == null ? -1 : rate.id.toString()"
        ... />

assuming the 'rate' property is a bean of the same type contained in 
'rateList'. If it's just an int/Integer, byte/Byte or similar the 'value' 
expression would elide the property accessor ('.id') part. 

Note: I haven't tested this work-around with primitive typed IDs, but I think 
it should work there too.

> s:select tag does not support keys of type Byte (and possibly others)
> ---------------------------------------------------------------------
>
>                 Key: WW-1601
>                 URL: https://issues.apache.org/struts/browse/WW-1601
>             Project: Struts 2
>          Issue Type: Improvement
>    Affects Versions: 2.0.2
>         Environment: windows xp, java 6, tomcat 5.5.17
>            Reporter: Dariusz Wojtas
>             Fix For: Future
>
>
> <s:select size="1" 
>     name="rate" 
>     list="rates" 
>     listKey="id" 
>     listValue="name" 
>     emptyOption="false" 
>     label="...."/>
> Action has properties
>   private Byte rate;
>   private ArrayList<OptionBean> rates;
> class OptionBean implements Serializable {
>    private Byte id;
>    private String name;
> }
> generated select tag does not recognize selected value.
> If I switch Byte to String then it works.
> I would like set OptionBean containing 'id' of type Object.
> And I tried it with different types of Objects (String, Byte) but only String 
> worked.
> I believe it should support all object types with correctly implemented 
> 'equals'.
> If it matters - form is of theme "ajax".

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

Reply via email to