2 Replies Latest reply on Nov 13, 2008 9:57 AM by Nikolay Elenkov

    Stupid <br> question

    Grzegorz Bernas Newbie

      Hi, sorry for stupid question but I can't find any information about:
      I have <h:inputTextarea /> and I want to disable HTML tags but when I display content of this I want to convert new line characters to <br />

      How to do it?

        • 1. Re: Stupid <br> question
          Mikael Andersson Master


          You could create a Facelets function or a Seam component to do this (since the enhanced EL allows for parameter passing).

          public class MyHelper ...{
            public String nlToBr(final String str){
               String retVal = null;
               retVal = //replacing the new lines
               return retVal;

          Then in the xhtml you can do this:

          <h:outputText value="#{myHelper.nlToBr(myBacking.theText)}"/>

          Or create a facelets function and have this:

          <h:outputText value="#{foo:nlToBr(myBacking.theText)}"/>

          - Micke

          • 2. Re: Stupid <br> question
            Nikolay Elenkov Master

            If all you want to do is preserve line breaks when displaying user-entered text,
            you could just set white-space: pre in CSS for your text areas. Like so:

            <h:inputTextarea rows="3" cols="40" readonly="true" 
               value="#{mybean.remark}"  style="white-space: pre" />