• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing formatted text to the user

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right now, if a user enters text into a text box and saves that information, when it is redisplayed to them or another user the formatting is, as expected, wrong.

Newlines, spaces, etc all get jumbled into a single space as per the html standard.

For example if they type:




it comes out as:



Is there an easy way to remedy this? My first thought it to pass the text through a filter that replaces all newlines with an html break element but I feel JSF must provide some easier solution. My second thought may be to just display the text using another textArea but leave it disabled so as to only display the information, but this seems quite backwards.

Does anyone have any better ideas for me?
 
Saloon Keeper
Posts: 27797
196
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
JSF is at the mercy of HTML on this one.

You can use a rich text editing extension JSF tag, but most of those simply allow the editing and display of HTML, so you'll still be at the mercy of HTML's restrictions, just able to handle fancier formats such as boldface and italics.
 
John Tannel
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim,

I ended up just filtering newlines and carriage returns to <br/> and then turning off escape on the outputText. It's not perfect, but it looks pretty darn good. It accomplishes what we want - allowing the user to have paragraphs and create crude lists in the textbox.

John
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic