You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2007/02/02 02:29:34 UTC

Re: [s2] s:select and non-primitive values

Stuart Piltch wrote:
> Laurie Harper <laurie <at> holoweb.net> writes:
>> <s:select name="region" list="regions"
>>            listKey="id" listValue="name"
>>            headerKey="-1" headerValue=""
>>            label="Region:" labelposition="left"/>
> 
> Hi Laurie,
> 
> I ran into a similar problem a few days ago. I posted my workaround here:
> 
> http://article.gmane.org/gmane.comp.jakarta.struts.user/134624
> 
> Since then, I've been using FreeMarker for some of the results. That ends up
> giving one more workaround:
> 
> Using your example (ignoring the Region converter for now), this would work in
> FreeMarker:
> 
> <@s.select name="regionId" list="regions" listKey="id" listValue="name" 
>            headerKey="-1" headerValue=""
>            label="Region:" labelposition="left" value="regionId.toString()" />
> 
> If you wanted to keep this workaround in the JSP itself, without using the
> Integer/String workaround in the model that I mentioned above, you'd have to do
> something like this:
> 
> <s:select name="regionId" list="regions" listKey="id" listValue="name" 
>            headerKey="-1" headerValue=""
>            label="Region:" labelposition="left" 
>            value="regionId == null ? '-1' : regionId.toString()" />
> 
> A bit ugly, but it should do the job until the bugs are fixed.
> 
> Cheers,
> 
>  - stuart

Stuart, nice workaround! :-) I added a comment to the JIRA ticket.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org