views:

197

answers:

2

Hi, 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"&gt;
       <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 ???

A: 

that's a jstl tag. it doesn't need to be translated. it's compiled from a jsp into a servlet.

what did you expect it to be "translated" into?

duffymo
I have edit my question. Maybe you will understand it better.I suppose that <fmt:formatDate value="${myBean.date}" pattern="dd/MM/yyyy"/> should generate this HTML code "<p>24/08/2009</p>".Not in my case, and it's the problem!<fmt:formatDate value="${myBean.date}" pattern="dd/MM/yyyy"/> generate this HTML code :<fmt:formatDate value="${myBean.date}" pattern="dd/MM/yyyy"/>
+1  A: 

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

harto
harto, thank you very much for this answer who work.Moreover your link is very usefull !