ADF

How to output text with line breaks in ADF ?

Problem

Suppose you have multinline (i.e. af:inputText) text field. User fills form by entering some multiple lines in there. Later on you have to display this text in readonly form. You can do this for sure by just adding attribute readonly=”true” or using af:outputText component.

Just one issue pops out – there is no multiple lines which user entered – whole text is displayed in single long line. How to have it multiline?

Solution

Such an issue happens, because af:inputText saves text using operating system new line symbols (i.e. “n” or “rn”, depends on which OS is used). Text is displayed in one line regardless of those symbols.

You need to use “af:outputFormatted” component instead. But it is not enough. While it does not understand “n” or rn” symbols, you need to use HTML <br> tag. Thus need to translate text manually by using custom java method.

Check my another post which covers exact sample you need –  How to pass parameter to method using expression language (EL) in ADF? .

JDeveloper/ADF Version 12.2.1.0.0