• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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: 28745
211
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic