Javax.faces.view.facelets.FaceletException: Error parsing /my.xhtml: Trace error [line: 42] "f" prefix for "f: facet" element is not associated

I would like to create a table that can map data from a database to a JSF page. I found this code:

<h:dataTable value="#{bookStore.items}" var="store">
  <h:column>
    <f:facet name="header">
      <h:outputText  value="#{msg.storeNameLabel}"/>
    </f:facet>
    <h:outputText value="#{store.name}"/>
  </h:column>
  <h:column>
    <f:facet name="header">
      Subject
    </f:facet>
    <h:outputText value="#{store.subject}"/>
  </h:column>
  <h:column>
    <f:facet name="header">
      <h:outputText  value="#{msg.storePriceLabel}"/>
    </f:facet>
    <h:outputText value="#{store.price}"/>
  </h:column>
</h:dataTable> 

      

When I use this code, I get this error message in Netbeans:

javax.faces.view.facelets.FaceletException: error parsing /my.xhtml: error in trace [line: 42] "f" prefix for "f: facet" element is not associated

If you replace a tag f

with a tag h

, will it work? Or do I need to include the tag library f

?

+3


source to share


3 answers


You must include the correct taglib for the f prefix.

Below is an example of a FaceSpace 2.2 page:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

...
</html>

      



If you are still using JSF 2.0 / 2.1 then use domain java.sun.com

instead of domain xmlns.jcp.org

in XML namespace.

I recommend reading the JSF tutorial, you can find links in our JSF wiki page .

+14


source


Replacing f

with h

won't work as there isn't h:facet

(in the JSF html taglib that can be prefixed h

). You will need to include the appropriate taglib (JSF core) and prefix it f

.



+2


source


Include taglib. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

0


source







All Articles