Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display html text within a Wicket element?

i'm trying to display html i.e. rich text within a wicket element dynamically. An example is like displaying a rich text email within a div tag. how can i get this done with wicket. the wicket Label component doesn't seem to support this. is there a component that does

like image 688
Emotu Balogun Avatar asked Nov 26 '09 15:11

Emotu Balogun


1 Answers

Found this in the excellent Manning Wicket in Action:

add(new Label("markup", "<h1>Hello!</h1>").setEscapeModelStrings(false));

The call to setEscapeModelStrings tells Wicket not to escape the contents of the provided string, and to render the contents into the resulting markup. This does the trick, as you can see in the right screenshot in figure 5.4. Note that this setting is available on all Wicket components, but it’s primarily useful on labels.

As the book also notes however, you should be aware of script-injection attacks..

like image 117
Tim Avatar answered Oct 20 '22 17:10

Tim