You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vincent Lin <vi...@gmail.com> on 2007/06/05 17:12:08 UTC

[S2] map to boolean property not checked

I have a java bean serviceData with a Boolean property autoActivate in my
action.
And I wrote a <s:radio/> tag in my JSP:

<s:radio label="autoActivate" name="serviceData.autoActivate"
            list="#{'true':'true', 'false':'false'}" />

But the default radio button is not checked in my page.
(While autoActivate is true the radio button of 'true' should be checked,
but it isn't.)

It works when I map <s:select/> to java 1.5 enum, but it doesn't work when I
map <s:radio> to java.lang.Boolean.
Did I do anything wrong?

Thanks.

Re: [S2] map to boolean property not checked

Posted by Torsten Römer <to...@luniks.net>.
I think you have the same problem as I just had. Because you put the
values as literals in <s:radio>, the tag ends up comparing a String
"true" against a Boolean true which of course returns false.

Could you try the tag like this:

<s:radio label="autoActivate" name="serviceData.autoActivate"
         list="#{true:'true', false:'false'}" />

Torsten

Vincent Lin schrieb:
> I have a java bean serviceData with a Boolean property autoActivate in my
> action.
> And I wrote a <s:radio/> tag in my JSP:
> 
> <s:radio label="autoActivate" name="serviceData.autoActivate"
>            list="#{'true':'true', 'false':'false'}" />
> 
> But the default radio button is not checked in my page.
> (While autoActivate is true the radio button of 'true' should be checked,
> but it isn't.)
> 
> It works when I map <s:select/> to java 1.5 enum, but it doesn't work
> when I
> map <s:radio> to java.lang.Boolean.
> Did I do anything wrong?
> 
> Thanks.
> 

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