Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use <h:outputText> to print static text?

Tags:

jsf-2

Should I use <h:outputText value="static text"/> or directly write static text into the xhtml file to print text that is static?

Example - with output text:

<h:outputText value="User Name:"/>
<h:outputText value="#{currentUser.name}"/>

Example - directly:

User Name:
<h:outputText value="#{currentUser.name}"/>
like image 436
Ralph Avatar asked Mar 28 '12 17:03

Ralph


1 Answers

Just write it directly into the page without the outputText. You even can write el expressions without a tag. So you could write:

User name: #{currentUser.name}

The outputText is needed (among others) if you want to change the text with ajax, render it conditionally or if you want to apply certain styles to the text.

like image 78
Matt Handy Avatar answered Oct 15 '22 14:10

Matt Handy