Question

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

Was it helpful?

Solution

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..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top