You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Lu <st...@lululand.com> on 2010/06/24 07:34:28 UTC

How to render HTML in Form Tag Label?

Hi All,

As part of a registration form, I want to have a checkbox that
lets the user agree to some terms:

( ) I agree to the _Terms of Service_

Where _Terms of Service_ should be a link to another page
with some legal mumbo jumbo.

The obvious code is:

<s:checkbox label="I agree to the <a href='legal.html'>Terms of 
Service</a>" name="agreeToTerms"/>

Unfortunately the HTML for <a> is encoded and rendered as code,
rather than as HTML:

( ) I agree to the <a href='legal.html'>Terms of Service</a>

Viewing the source shows that < and > have been changed to
&lt; and &gt;, respectively.

Is there a way to tell struts not to use the label text as-is?

                   - David -



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


Re: How to render HTML in Form Tag Label?

Posted by Dale Newfield <da...@newfield.org>.
On 6/28/10 4:16 AM, David Lu wrote:
> I ended up just rendering that particular checkbox myself
> using standard JSP and HttpServletRequest, doing things the
> "old fashioned" way. :)

If you want the checkbox interceptor to work, you need a corresponding 
hidden input field...you might want to render the label yourself but 
still use struts2 (and the simple theme) to render the checkbox and 
hidden field.

-Dale

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


Re: How to render HTML in Form Tag Label?

Posted by David Lu <st...@lululand.com>.
Hi Pawel,

Thanks for the suggestion.  <s:checkbox> draws a table row
so one can't really put anything outside of it and still
have it rendered next to the checkbox.

I ended up just rendering that particular checkbox myself
using standard JSP and HttpServletRequest, doing things the
"old fashioned" way. :)

                      - David -


On 06/26/2010 01:04 AM, Paweł Wielgus wrote:
> Hi David,
> try:
> <s:checkbox name="..." value="...">  I agree to<  a href="...">terms of
> service</ a>  </s:checkbox>
> I don't remeber if it will work in struts2
> but if not You can always use theme="simple" and no label at all in
> s:checkbox and add text after checkbox in any form You like.
>
> Best greetings,
> Paweł Wielgus.
>
>
> 2010/6/24 David Lu<st...@lululand.com>:
>>
>> Hi All,
>>
>> As part of a registration form, I want to have a checkbox that
>> lets the user agree to some terms:
>>
>> ( ) I agree to the _Terms of Service_
>>
>> Where _Terms of Service_ should be a link to another page
>> with some legal mumbo jumbo.
>>
>> The obvious code is:
>>
>> <s:checkbox label="I agree to the<a href='legal.html'>Terms of Service</a>"
>> name="agreeToTerms"/>
>>
>> Unfortunately the HTML for<a>  is encoded and rendered as code,
>> rather than as HTML:
>>
>> ( ) I agree to the<a href='legal.html'>Terms of Service</a>
>>
>> Viewing the source shows that<  and>  have been changed to
>> &lt; and&gt;, respectively.
>>
>> Is there a way to tell struts not to use the label text as-is?
>>
>>                   - David -
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

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


Re: How to render HTML in Form Tag Label?

Posted by Paweł Wielgus <po...@gmail.com>.
Hi David,
try:
<s:checkbox name="..." value="..."> I agree to < a href="...">terms of
service</ a> </s:checkbox>
I don't remeber if it will work in struts2
but if not You can always use theme="simple" and no label at all in
s:checkbox and add text after checkbox in any form You like.

Best greetings,
Paweł Wielgus.


2010/6/24 David Lu <st...@lululand.com>:
>
> Hi All,
>
> As part of a registration form, I want to have a checkbox that
> lets the user agree to some terms:
>
> ( ) I agree to the _Terms of Service_
>
> Where _Terms of Service_ should be a link to another page
> with some legal mumbo jumbo.
>
> The obvious code is:
>
> <s:checkbox label="I agree to the <a href='legal.html'>Terms of Service</a>"
> name="agreeToTerms"/>
>
> Unfortunately the HTML for <a> is encoded and rendered as code,
> rather than as HTML:
>
> ( ) I agree to the <a href='legal.html'>Terms of Service</a>
>
> Viewing the source shows that < and > have been changed to
> &lt; and &gt;, respectively.
>
> Is there a way to tell struts not to use the label text as-is?
>
>                  - David -
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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