Monday, May 5, 2014

Simple and Easy way to display line breaks in outputText without converting it to InputText

Write a java bean that would replace each occurrence of  \n with <br/>

 public String getDescription() {
        String description = (String)JSFUtils.resolveExpression("#{row.Description}");
        if (description != null)
            description = description.replaceAll("\n", "<br/>");
        return description;

In jsf page set escape outputText property to false:
<af:outputText value="#{myBean.description}" id="ot2" escape="false"/>

The result should look like this:


  1. This comment has been removed by the author.

  2. Can you please explain it more clearly, like where should I store description kind.....