You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Francisco Diaz Trepat - gmail <fr...@gmail.com> on 2007/11/12 20:40:51 UTC

Label: Render HTML content from String

Hi, I have a Label who's model maight come with markup for bold italic,
bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")

Obviously I get "<b>This</b> is a <i>Message</i>" rendered.

Is there a way to get the label to render:

"*This* is a *Message*"

thanks,
f(t)

Re: Label: Render HTML content from String

Posted by Francisco Diaz Trepat - gmail <fr...@gmail.com>.
It seams the formatted message I set didn't show well.

I want to (as the subject says) Render HTML content from the String.

Is there a way to get the label to render:

"*This* is a *Message*" [this line here and in the original message is
formatted with bold and italics]

On Nov 12, 2007 5:02 PM, Sebastiaan van Erk <se...@sebster.com> wrote:

> Hehe, nasty! :-)
>
> I suggest doing it in one replaceAll though:
>
> text.replaceAll("<[^>]*>", "*")
>
> This has the added benefit of correctly treating unexpected and as yet
> unknown tags, and thus is more future proof!
>
> Regards,
> Sebastiaan
>
> Martijn Dashorst wrote:
> > this should get what you want:
> > add(new Label("foo", text.replaceAll("<b>", "*")
> >     .replaceAll("</b>", "*")
> >     .replaceAll("<i>", "*")
> >     .replaceAll("</i>", "*")));
> >
> > Martijn
> >
> > On 11/12/07, Francisco Diaz Trepat - gmail
> > <fr...@gmail.com> wrote:
> >> Hi, I have a Label who's model maight come with markup for bold italic,
> >> bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")
> >>
> >> Obviously I get "<b>This</b> is a <i>Message</i>" rendered.
> >>
> >> Is there a way to get the label to render:
> >>
> >> "*This* is a *Message*"
> >>
> >> thanks,
> >> f(t)
> >>
> >
> >
>

Re: Label: Render HTML content from String

Posted by Sebastiaan van Erk <se...@sebster.com>.
Hehe, nasty! :-)

I suggest doing it in one replaceAll though:

text.replaceAll("<[^>]*>", "*")

This has the added benefit of correctly treating unexpected and as yet 
unknown tags, and thus is more future proof!

Regards,
Sebastiaan

Martijn Dashorst wrote:
> this should get what you want:
> add(new Label("foo", text.replaceAll("<b>", "*")
>     .replaceAll("</b>", "*")
>     .replaceAll("<i>", "*")
>     .replaceAll("</i>", "*")));
> 
> Martijn
> 
> On 11/12/07, Francisco Diaz Trepat - gmail
> <fr...@gmail.com> wrote:
>> Hi, I have a Label who's model maight come with markup for bold italic,
>> bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")
>>
>> Obviously I get "<b>This</b> is a <i>Message</i>" rendered.
>>
>> Is there a way to get the label to render:
>>
>> "*This* is a *Message*"
>>
>> thanks,
>> f(t)
>>
> 
> 

Re: Label: Render HTML content from String

Posted by Martijn Dashorst <ma...@gmail.com>.
this should get what you want:
add(new Label("foo", text.replaceAll("<b>", "*")
    .replaceAll("</b>", "*")
    .replaceAll("<i>", "*")
    .replaceAll("</i>", "*")));

Martijn

On 11/12/07, Francisco Diaz Trepat - gmail
<fr...@gmail.com> wrote:
> Hi, I have a Label who's model maight come with markup for bold italic,
> bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")
>
> Obviously I get "<b>This</b> is a <i>Message</i>" rendered.
>
> Is there a way to get the label to render:
>
> "*This* is a *Message*"
>
> thanks,
> f(t)
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-rc1 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-rc1/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Label: Render HTML content from String

Posted by Francisco Diaz Trepat - gmail <fr...@gmail.com>.
Bolshoi Spasiba Gaspadin!!!!



On Nov 12, 2007 5:11 PM, Dmitry Kandalov <no...@gmail.com> wrote:

>  On Monday 12 November 2007 23:40:51 Francisco Diaz Trepat - gmail wrote:
> > Hi, I have a Label who's model maight come with markup for bold italic,
> > bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")
> >
> > Obviously I get "<b>This</b> is a <i>Message</i>" rendered.
> >
> > Is there a way to get the label to render:
> >
> > "*This* is a *Message*"
>
> Hm.. just in case you wanted label look bold and italic you can use
> label.setEscapeModelStrings(false)
>
>
> Dima
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Label: Render HTML content from String

Posted by Dmitry Kandalov <no...@gmail.com>.
On Monday 12 November 2007 23:40:51 Francisco Diaz Trepat - gmail wrote:
> Hi, I have a Label who's model maight come with markup for bold italic,
> bullets, etc. (e.g. "<b>This</b> is a <i>Message</i>")
>
> Obviously I get "<b>This</b> is a <i>Message</i>" rendered.
>
> Is there a way to get the label to render:
>
> "*This* is a *Message*"

Hm.. just in case you wanted label look bold and italic you can use 
label.setEscapeModelStrings(false)


Dima

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org