JSF h:outputText with body and value attribute
December 03, 2011 12:31:20 Last update: December 03, 2011 12:33:23
The
With value attribute, the output was:
With text in body, the output was (i.e., the text was escaped despite
<h:outputText> tag generates different output for body text and value attribute. I tested the following with Apache MyFaces 2.1.3:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>outputText test</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </h:head> <h:body> <div id="header"><h2>Test h:outputText</h2></div> <div id="content"> <h:outputText escape="false" value="<table border='1' cellspacing='0' cellpadding='4'>"/> <tr><td>Table cell</td></tr> <h:outputText escape="false" value="</table>"/> <h:outputText escape="false"> <table border='1' cellspacing='0' cellpadding='4'> </h:outputText> <tr><td>Table cell</td></tr> <h:outputText escape="false"> </table> </h:outputText> </div> </h:body> </html>
With value attribute, the output was:
<table border='1' cellspacing='0' cellpadding='4'> <tr><td>Table cell</td></tr></table>
With text in body, the output was (i.e., the text was escaped despite
escape="false"):
<table border='1' cellspacing='0' cellpadding='4'> <tr><td>Table cell</td></tr> </table>