I have following Primefaces page and controller.
Page
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile">
<f:view renderKitId="PRIMEFACES_MOBILE"/>
<h:head>
</h:head>
<h:body id="body">
<pm:page id="page">
<pm:header title="MyProduct">
</pm:header>
<pm:content id="content">
<p:dataList value="#{likeditems.likedItems}" var="item" pt:data-inset="true" paginator="true" rows="5">
<f:facet name="header">
List of Cars
</f:facet>
<h:outputLink value="#{item.url}">
<h2>#{item.title}</h2>
<p>#{item.price}</p>
<p class="ui-li-aside"><strong>XXXX</strong></p>
</h:outputLink>
<f:facet name="footer">
List of Cars
</f:facet>
</p:dataList>
<p:outputLabel
id="priceHint"
value="..."
cache="false"/>
</pm:content>
<pm:footer title="m.MyProduct.info"></pm:footer>
</pm:page>
</h:body>
</html>
Controller
@ManagedBean(name = LikedItemsView.NAME)
@SessionScoped
public class LikedItemsView {
public static final String NAME = "likeditems";
public List<LikedItem> getLikedItems()
{
final LikedItem item1 = new LikedItem();
item1.setTitle("Product 1");
item1.setPrice(Money.of(CurrencyUnit.USD, 20));
item1.setUrl("http://google.com");
final LikedItem item2 = new LikedItem();
item2.setTitle("Product 2");
item2.setPrice(Money.of(CurrencyUnit.USD, 30));
item2.setUrl("http://yandex.ru");
final List<LikedItem> items = new LinkedList<LikedItem>();
items.add(item1);
items.add(item2);
return items;
}
}
When I access the page, I get following error:
servlet.ServletException: Error Parsing /likeditems.xhtml: Error Traced[line: 31] The prefix "pt" for attribute "pt:data-inset" associated with an element type "p:dataList" is not bound.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
Line 31 is this:
<p:dataList value="#{likeditems.likedItems}" var="item" pt:data-inset="true" paginator="true" rows="5">
How can I fix this error?
The data-inset
attribtue isn't natively supported by <p:dataList>
. Moreover, all attribute names prefixed with data-*
are most definitely HTML5 related. So removing the pt
prefix as suggested by someone else isn't the right solution. The attribute wouldn't be rendered at all. You could as good just remove the entire attribute altogether.
The XML namespace prefix pt
suggests a shorthand for "passthrough" and the attribute is in this particular snippet recognizable as a passthrough attribute. This is a JSF 2.2 specific feature, part of "HTML5 friendly markup".
The correct XML namespace URI for that is http://xmlns.jcp.org/jsf/passthrough
.
<html ... xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
Do note that the offical XML namespace prefix is p
(see also that tutorial), but it otherwise clashes with the one for PrimeFaces. I myself would personally use a
, standing for "attribute".
<html ... xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
...
<p:dataList ... a:data-inset="true">
If you aren't using JSF 2.2, or don't have any use for that attribute in client side, then, well, just remove it altogether. It's apparently leftover from copypasted code.