Use JSTL tags in JSF 2.0 facelets
November 07, 2011 09:41:57 Last update: November 07, 2011 09:42:25
Using JSTL tags in JSF facelets is quite simple: just add the XML namespace for the JSTL tags and use them in the page.
An example of using the
An example of using the
<c:if>
tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"http://www.xinotes.org/notes/add/ xmlns:c="http://java.sun.com/jsp/jstl/core"> <h:head> <title>Use JSTL in JSF 2.0 Facelets</title> </h:head> <h:body> <c:if test="#{param['name'] != null}"> <h1>Hello #{param['name']}!</h1> </c:if> <c:if test="#{param['name'] == null}"> <h1>Hello Anonymous!</h1> </c:if> </h:body> </html>