【问题标题】:Is there a way to know which components got updated upon action有没有办法知道哪些组件在操作时更新
【发布时间】:2015-12-10 01:05:04
【问题描述】:

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

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

问题是:我现在不知道。因此,为了推断错误所在,最好以某种方式真正确保commandButtonupdate 部分有效。

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

【问题讨论】:

    标签: jsf primefaces rerender


    【解决方案1】:

    使用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-10
      • 2016-10-17
      • 2011-01-13
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      • 1970-01-01
      • 2019-07-31
      相关资源
      最近更新 更多