struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: [s2] s:select and non-primitive values
Date Fri, 02 Feb 2007 01:29:34 GMT
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


Mime
View raw message