This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Prevent Struts2 escaping html in labels? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Prevent Struts2 escaping html in labels?" Watch "Prevent Struts2 escaping html in labels?" New topic

Prevent Struts2 escaping html in labels?

Xolani Nkosi
Ranch Hand

Joined: Apr 29, 2009
Posts: 32
Hi all.

I'd like to use a jquery-ui icon on a struts2 button to add a bit of visual flair to an app. The code in the jsp looks something like:

And my text is:

This almost does what I'd like, except somewhere along the line the html in the message has been escaped. The html generated looks like:

Any ideas what is doing the escaping and how to stop it? Or if anyone has done what I'm attempting and has a better way of doing it (preferably that will allow adding icons to buttons to be made via changes only)
David Newton

Joined: Sep 29, 2008
Posts: 12617

You might have to change the template or use normal CSS. The current "xhtml" theme templates (css_xhtml might be a little better, I know someone made some enhancements to it) aren't super-good at exposing ids/classes to CSS.

All that said I'd really recommend against putting markup stuff in resource files unless there's a *really* good reason to do so. Since the label field would be accessible using straight CSS I don't think this is one of the places where it'd be necessary.
I agree. Here's the link:
subject: Prevent Struts2 escaping html in labels?
It's not a secret anymore!