0

我遇到了 JSF 的问题,我有一个在所有页面上呈现的片段,并显示表的最新条目(约 10 个项目)。我想在列出所有条目的页面上重用它。

我设置了一个渲染规则,以防止元素的所有页面版本专门出现在此页面上,但仍然不行,我得到一个“在视图中发现重复的 id”错误。问题似乎在于 JSF 处理器在验证哪些 ID 将真正呈现之前验证 ID。

仅供参考,我使用请求 URI 的结尾来确定呈现的是 True 还是 False。

啊,我尝试使用 c:if,但它也没有用。

编辑:

请求示例代码...

我有这个 xhtml 片段(“tableInclude.xhtml”):

<ui:composition
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <ui:fragment>
        <p:dataTable var="item" value="#{bean.items}"
                     emptyMessage="#{msg['table.empty']}"
                     widgetVar="table" id="listItems" styleClass="tableItems">
            <p:column styleClass="span1" style="text-align: center;">
                <f:facet name="header">
                    <i class='fa-icon-picture'/>
                </f:facet>
                <p:commandLink action="#{bean.itemSelected(item)}" value="#{item.name}"/>
            </p:column>
        </p:dataTable>
    </ui:fragment>
</ui:composition>

然后我在每个页面上运行:

<ui:include src="./tableInclude.xhtml">

我试图这样做:

<ui:fragment rendered="#{request.requestURI != '/context/don't_render_here.xhtml'}">
    <ui:include src="./tableInclude.xhtml">
</ui:fragment>

但即使如此,当我访问“don't_render_here.xhtml”页面时,我仍然会收到重复的 id 错误。

4

1 回答 1

1

不是最好的解决方案,而是快速而肮脏的:替换ui:fragmentf:subView

于 2014-02-28T16:13:29.603 回答