Search code examples
jsfjstltagstranslate

JSF tag not found


I use JSF-facelets.jar 1.1.14 (I downloaded it here) and tomcat 6.0

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_12-b04 (Sun Microsystems Inc.)
Implementation-Version: 1.1.14

If I understand well, JSF-facelets.jar = JSF + JSTL + Facelets (???)


My problem is when I use "fmt" fonction.

This code...

  <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:fmt="http://java.sun.com/jstl/fmt">
       <h:outputLabel value="hello" />
       <fmt:formatDate value="${myBean.date}" pattern="dd/MM/yyyy"/>
  </html>

...generate this HTML code:

  <html>
        <p>hello</p>
        <fmt:formatDate value="${myBean.date}" pattern="dd/MM/yyyy"/>
  </html>



Why "fmt:formatDate" is not change into HTML code ???


Solution

  • The correct way to achieve this in JSF is to use converters. Use the <h:outputText> tag like so:

    <h:outputText value="#{myBean.date}">
        <f:convertDateTime pattern="dd/MM/yyyy" />
    </h:outputText>
    

    You'll find that not all JSTL tags are supported in JSF. Facelets does provide limited support for the core tag library (forEach, etc) but they might not work the way you expect them to. This article provides a good summary: http://drewdev.blogspot.com/2008/03/build-time-vs-render-time.html