If you are using a simple '\n', then every html encoding I know will do the right thing out of the box. I used to use commons StringEscapeUtils [1]
LieGrue, strub [1] http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml%28java.lang.String%29 --- Jakob Korherr <[email protected]> schrieb am Mo, 22.2.2010: > Von: Jakob Korherr <[email protected]> > Betreff: Re: How to elegantly replace line breaks with <BR> tag? > An: "MyFaces Discussion" <[email protected]> > Datum: Montag, 22. Februar, 2010 20:17 Uhr > Hmm. You could write your own JSF > component or you could try my suggested > solution from before and manually escape HTML entities! > > Or you know, you could use the HTML <pre> tag. > > Regards, > Jakob > > 2010/2/22 laredotornado <[email protected]> > > > > > I am printing back text the user entered so there is > no guarantee that they > > will enter it in a particular format. > > > > This can't be that hard ... replacing "\n" with > HTML-recognizable <BR> > > tags. > > Surprisingly, Google is coming up empty on this > one. Any additional help > > is > > appreciated, - Dave > > > > > > > > > > > > struberg wrote: > > > > > > why not use <ul> and <li> elements > and later format your output via CSS? > > > > > > LieGrue, > > > strub > > > > > > --- laredotornado <[email protected]> > schrieb am Mo, 22.2.2010: > > > > > >> Von: laredotornado <[email protected]> > > >> Betreff: Re: How to elegantly replace line > breaks with <BR> tag? > > >> An: [email protected] > > >> Datum: Montag, 22. Februar, 2010 19:34 Uhr > > >> > > >> Will JSF escape the "<BR/>" and make > it > > >> "<BR/>"? I still want > other > > >> "HTML" characters like "&" and "<" > escaped. > > >> > > >> - Dave > > >> > > >> > > >> > > >> Jakob Korherr wrote: > > >> > > > >> > Hi, > > >> > > > >> > You can provide a special getter method > in your > > >> managed bean for that > > >> > (something like > getResultWithLineBreaks()) and replace > > >> "\n" with "<br />" > > >> > in > > >> > the return value of method. Then you > have to change > > >> your t:outputText > > >> > component to: > > >> > > > >> > <t:outputText > > >> value="#{currentRow.resultWithLineBreaks}" > escape="false" > > >> /> > > >> > > > >> > Regards, > > >> > Jakob > > >> > > > >> > 2010/2/22 laredotornado <[email protected]> > > >> > > > >> >> > > >> >> Hi, > > >> >> > > >> >> I'm using MyFaces 1.1.5 with > Tomahawk 1.1.7 (Java > > >> 1.5, Resin, 3.0.19). > > >> >> Is > > >> >> there a way in JSF where I can > replace the "\n" > > >> (chr(13) carriage return > > >> >> character) with the "<BR/>" > tag in my > > >> outputText block? Right now I have > > >> >> > > >> >> <t:outputText > value="#{currentRow.result}" > > >> /> > > >> >> > > >> >> Thanks, - Dave > > >> >> -- > > >> >> View this message in context: > > >> >> > > >> > > http://old.nabble.com/How-to-elegantly-replace-line-breaks-with-%3CBR%3E-tag--tp27690198p27690198.html > > >> >> Sent from the MyFaces - Users > mailing list archive > > >> at Nabble.com. > > >> >> > > >> >> > > >> > > > >> > > > >> > > >> -- > > >> View this message in context: > > >> > > http://old.nabble.com/How-to-elegantly-replace-line-breaks-with-%3CBR%3E-tag--tp27690198p27692067.html > > >> Sent from the MyFaces - Users mailing list > archive at > > >> Nabble.com. > > >> > > >> > > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Sie sind Spam leid? Yahoo! Mail verfügt über > einen herausragenden Schutz > > > gegen Massenmails. > > > http://mail.yahoo.com > > > > > > > > > > -- > > View this message in context: > > http://old.nabble.com/How-to-elegantly-replace-line-breaks-with-%3CBR%3E-tag--tp27690198p27692517.html > > Sent from the MyFaces - Users mailing list archive at > Nabble.com. > > > > > __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com

