Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

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

Laurie Harper

2007-02-01

Replies:

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:
>
> <@(protected)"
>        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@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.