• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

JSF Expression Language and HTML

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have data stored in the database as text strings with embedded HTML tags (like links, bold characters, etc.). It get retrieved just fine, until it is inserted into XHTML page using EL expression syntax #{expression}. EL escapes all HTML special characters, which results in displaying it as plain text on XHTML page.

Is there any way how to disable this default JSF EL behavior - coersion rule? Maybe overwrite some class?

Thanks

Alex
 
Alex Balaban
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I can answer that myself....
The answer is to use JSF tag <h:outputText value="#{reference}" escape="false"/> and set that escape to false.


Alex
 
Saloon Keeper
Posts: 23266
158
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just as a general precaution, however, I don't recommend having the backing layer emit display elements (HTML). There are times when it's necessary and I'm presently working on an app that does so. But that's because the app uses an HTML editor to input and display data (rather like the one that JavaRanch uses for postings).

I've seen - and suffered with - a number of webapps that output table rows with tags in them and committed various other offenses. It tends to be a real pain, since sooner or later there always seems to arise a need for just the data without the HTML. And having the display come from 2 different layers (JSF and Java code) can make both predicting output and finding what to change a real game of hide-and-seek.

So unless the HTML formatting is part of the backing data itself, I strongly urge that you put all the HTML (and CSS references) on the JSF pages, not in the backing beans.
 
I'm full of tinier men! And a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic