前缀"pt"是指对于属性"pt:data-inset"与元素类型"p:dataList"相关联.没有约束 [英] The prefix "pt" for attribute "pt:data-inset" associated with an element type "p:dataList" is not bound

查看:105
本文介绍了前缀"pt"是指对于属性"pt:data-inset"与元素类型"p:dataList"相关联.没有约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Primefaces页面和控制器.

I have following Primefaces page and controller.

页面

<!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>

控制器

@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)

第31行是这样:

<p:dataList value="#{likeditems.likedItems}" var="item" pt:data-inset="true" paginator="true" rows="5">

如何解决此错误?

推荐答案

data-inset属性/primefaces-p/dataList.html"rel =" nofollow> <p:dataList> .此外,所有带有data-*前缀的属性名称绝对是与HTML5相关.因此,按照其他人的建议删除pt前缀不是正确的解决方案.该属性将不会被渲染.您可以完全删除整个属性.

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.

XML名称空间前缀pt是"passthrough"的缩写,该属性在此特定代码段中可识别为passthrough属性.这是JSF 2.2的特定功能,是" HTML5友好标记".

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".

正确的XML名称空间URI是http://xmlns.jcp.org/jsf/passthrough.

The correct XML namespace URI for that is http://xmlns.jcp.org/jsf/passthrough.

<html ... xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">

请注意,正式的XML名称空间前缀为p(另请参阅该教程),但否则与PrimeFaces的名称冲突.我本人会亲自使用a来代表属性".

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">

如果您没有使用JSF 2.2,或者在客户端对该属性没有任何用处,那么,只需将其完全删除即可.显然是复制粘贴的代码中遗留下来的.

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.

这篇关于前缀"pt"是指对于属性"pt:data-inset"与元素类型"p:dataList"相关联.没有约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆