Primefaces 数据表不遵守渲染标签的条件限制

Primefaces datatable not obeying conditional restiriction of rendered tag

我有这样的代码:

<p:outputPanel id="conditionalPanel">
    <p:panel rendered="#{object.category.string == 'foo'}">
        <ui:param name="foo" value="#{object}"/>
        <h:panelGrid columns="3" id="fooAssignmentsuttonGrid">
            <h:outputLabel for="barToAdd" styleClass="desc" value="#{foobarzooUIData.label}"/>
            <h:selectOneMenu id="barToAdd" value="#{fooController.barToAdd}">
                <f:selectItems value="#{barsToAddAssignments}"
                               var="foobarzoo" itemValue="#{foobarzoo}" 
                               itemLabel="#{foobarzooUIData.buildLabelForObject(foobarzoo)}"/>
            </h:selectOneMenu>
            <p:commandButton value="#{text['button.add']}" process="@this barToAdd" 
                             update="assignmentDetail" disabled="#{empty barsToAddAssignments}"
                    action="#{fooController.createNewAssignment(foo)}">
            </p:commandButton>
        </h:panelGrid>
        <p:outputPanel id="fooAssignmentsTable">
            <p:dataTable value="#{utils:toList(foo.fooAssignments)}" var="assignment">
                <!-- p:columns here etc..-->
            </p:dataTable>
        </p:outputPanel>

        <p:outputPanel id="assignmentDetail">
            <p:panel rendered="#{not empty fooController.selectedAssignment}" style="margin-top: 30px;">
                <h:panelGrid id="assignmentDetailForm" styleClass="formsTable" columns="2">
                   <!-- Some kick ass code here -->
                </h:panelGrid>
            </p:panel>
        </p:outputPanel>
    </p:panel>
</p:outputPanel>

问题是,当我点击这个页面的时候

 object.category.string == 'foo'

不满意,还在补:

/test.xhtml @264,147 value="#{utils:toList(foo.fooAssignments)}": The class 'com.foo.bar.too does not have the property 'fooAssignments'.

是的,我知道这个class没有这个属性,但是这个根本不应该评价,不是吗?

我在这里错过了什么?

很遗憾您没有 post 完整的堆栈跟踪,因为它通常代表了整个答案本身,我可以将其翻译成外行人的术语。

通常这确实会在 component tree visit whereby the rendered attribute is not obeyed. The mention of the stack trace and the actual versions being used should reveal whether it's a "feature" or actually a bug in either the JSF impl being used, or in PrimeFaces. Generally I'd say that this would be a bug. This problem has before been observed with Mojarra's <ui:repeat> and has been fixed in that side. See also this related Q&A: PropertyNotFoundException on conditionally rendered subclasses in ui:repeat 期间发生。

如果升级到最新的 JSF impl 和 PrimeFaces 版本没有帮助,那么最好的办法是有条件地 构建 视图而不是有条件地呈现视图。 JSTL 在这方面很有帮助。另见 JSTL in JSF2 Facelets... makes sense?

<c:if test="#{object.category.string == 'foo'}">
    <p:panel>
        ...
    </p:panel>
</c:if>