I need to render a line break using outputText
so that I can utilize the rendered
attributed. I tried
That's indeed not valid since Facelets because it's syntactically invalid in XML. You'd need to manually escape the XML special characters like <
, >
and so on.
<h:outputText value="<br/>" escape="false" />
You can however just emit the <br/>
in template text without the need for a <h:outputText>
.
<br/>
To render it conditionally, wrap it in for example a <ui:fragment>
.
<ui:fragment rendered="#{bean.rendered}"><br /></ui:fragment>
A <h:panelGroup>
is also valid as it doesn't emit anything to the HTML anyway.
<h:panelGroup rendered="#{bean.rendered}"><br /></h:panelGroup>
You can try putting the "<br />"
inside a resource bundle and then get the value from that resource bundle.
JSF PAGE
<h:outputText value="#{car.crg}" escape="false" style="white-space: pre-wrap;word-wrap: break-word; " />
escape should be false
and write the bean Getter
method as follows
public String getCrg() {
return crg.replace("<br/>", "<br />");
//return crg;
}