0

I can't get on with the following task and I haven't even found any information about expression language functions in JSF which is able to help me. I have a task -

Display lines out which start in a new line

ManagedBean(name = "Bean_0") method that returns the lines is

public String task4() {
    String result = "";
    String surname = "Sckoriy";
    int i = 0;
    do {
        result += surname + "\n";
        i++;
    }while(i != 4);
    return result;
} 

Here is xhtml code -

<div class = "Container">
    <p class = "Task">#{Bean_0.getTask4()}</p>
    <p class = "Result">
    //Difficult is here
    //What's syntax must there be? 
    <h:outputText value = "#{fn:replace(Bean_0.task4(),'\n','&lt;br/&gt;')}" escape="false"/>
    </p>
</div>

I get the exception -

SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path 
[/Practice] threw exception [/Page.xhtml @34,78 value="# 
{fn:replace(Bean_0.task4(),'\n','<br/>')}" Failed to parse the expression [# 
{fn:replace(Bean_0.task4(),'\n','<br/>')}]] with root cause
org.apache.el.parser.ParseException: Encountered " <ILLEGAL_CHARACTER> "\' 
"" at line 1, column 29.
Was expecting one of:

"{" ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
"null" ...
"(" ...
"[" ...
"!" ...
"not" ...
"empty" ...
"-" ...
<IDENTIFIER> ...
<IDENTIFIER> ...
"(" ...
skoriy
  • 186
  • 10
  • First of all, welcome to StackOverflow. Following the advices of the community, it is recommended to include formatted text instead of images. Please check the documentation [on how to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Carlos Cavero Apr 23 '19 at 15:49
  • @Kukeltje , I've already used that desicion , but it doesn't work for me.I have a little another case - I should get result of method but not instance variable – skoriy Apr 23 '19 at 16:10
  • @Kukeltje , sorry but I am sure that I have unique questions.I have asked how to display out result method into expression language function fn:replace.There is instance variable in that desicion but not call method! – skoriy Apr 23 '19 at 16:22
  • @Sckoriy: You're using Apache EL not Oracle EL. – BalusC Apr 23 '19 at 18:48
  • @BalusC , in short , I have already done that.I've simply inserted
    where line should be separated and it works)After I have your comment I will certainly get a java ee developer in the future!)
    – skoriy Apr 23 '19 at 19:01
  • See, I was right. 100% what I commented (and removed due to your reactions). You don't specifically need a javaee developer, you need to read the duplicate carefully – Kukeltje Apr 24 '19 at 06:21

0 Answers0