myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From António Rodrigues <antonio.jose.rodrig...@gmail.com>
Subject Re: How to elegantly replace line breaks with <BR> tag?
Date Fri, 26 Feb 2010 15:48:44 GMT
I add that problem also because I wanted to display the text exactly as it
was entered in a text area.

You can create a custom converter and then add it to the components where
you want to use it.
But the most elegant way is to create a facelet.

This is what I did.
- I have created a custom converter that converts \n into <br/> and spaces
into &nbsp;
- I have created a facelet as follows.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <h:panelGroup rendered="#{empty rendered or rendered}">
        <h:outputLabel value="#{value}"
                       converter="ParagraphConverter"
                       escape="false"
                       styleClass="#{styleClass}">
        </h:outputLabel>
    </h:panelGroup>
</ui:composition>


So when I want a paragraph I just use the facelet tag

<mytags:textParagraph styleClass="paragraphFont"
rendered="#{myBean.display}" value="#{myBean.conclusion}" />


Cheers
AJCR



On 22 February 2010 17:45, laredotornado <laredotornado@gmail.com> wrote:

>
> 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.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message