0

在 JSF 2.2 中编程时,我有时不确定该update语句是否有效。例如,我有下表,并希望在单击按钮时更新它:

<h:form id="theform">

    <h:panelGroup id="entity">

        <p:dataTable
            var="item"
            tableStyle="width:auto"
            styleClass="tableFillRight"
            value="#{artistEntityBean.asList}"
            id="table">

            <p:column headerText="Name">
                <h:outputText value="#{item.name}" styleClass="tableArtistName" />
            </p:column>

            <f:facet name="footer">

                <h:panelGroup id="footerWrapper">

                    <p:commandButton
                        id="requestMod"
                        partialSubmit="true"
                        process="@this"
                        value="become moderator"
                        update="@parent :messages"
                        disabled="#{moderatorEntityBean.item.moderatingArtist}"
                        actionListener="#{moderatorEntityBean.handleCreate()}"
                        action="#{artistEntityBean.init()}">                            
                    </p:commandButton>

                </h:panelGroup>

            </f:facet>

        </p:dataTable>

    </h:panelGroup>

</h:form>

由于ID按钮是theForm:table:requestMod我认为这update="@parent"会起作用。但是,它似乎没有更新,或者我在支持 bean 的某个地方或其他地方犯了一个错误?

问题是:我现在没有。因此,为了推断错误所在,以某种方式真正确保update部分commandButton工作正常会很棒。

现在,当单击按钮时,更改的值仅在重新加载页面后更新。

4

1 回答 1

0

使用Firebug或类似的浏览器插件来监控网络并检查服务器的响应。如果组件(例如,clientId=component_client_id)被更新,您将看到如下内容:

<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
    <changes>
        <update id="component_client_id">
            <![CDATA[
                ... component's HTML code ...
            ]]>
         </update>
        <update id="j_id1:javax.faces.ViewState:0">
             <![CDATA[-74243231543289530:-219780152641895389]]>
        </update>
    </changes>
</partial-response>
于 2015-09-14T20:07:31.103 回答