Jsf p:remoteCommand更新属性与p:commandButton更新属性?

Jsf p:remoteCommand更新属性与p:commandButton更新属性?,jsf,primefaces,Jsf,Primefaces,我有以下代码块,当我从p:remote命令更新“pickList”时,它会被更新 <h:panelGrid columns="1"> <p:panel id="panel" header="Units" style="margin-bottom:10px; background:#F3F2F2; margin-bottom:0px

我有以下代码块,当我从p:remote命令更新“pickList”时,它会被更新

            <h:panelGrid columns="1">
            <p:panel id="panel" header="Units"
                style="margin-bottom:10px; background:#F3F2F2; margin-bottom:0px">

                <p:pickList id="pickList"
                    value="#{AdminController.unitsPickListAll}" var="selectedUnit"
                    itemLabel="#{selectedUnit}" itemValue="#{selectedUnit}" />

            </p:panel>

            <h:panelGrid columns="1" styleClass="right-alignment">
                <h:panelGroup>
                    <p:commandButton id="refereshButton" value="#{i18n.refresh}"
                        immediate="true" action="#{AdminController.getAllUnits}"
                        oncomplete="rc()" />
                    <h:outputText value="&#160;&#160;" />
                    <p:commandButton id="saveButton" value="#{i18n.save}"
                        action="#{AdminController.updateUsedUnits}" />
                        
                </h:panelGroup>
            </h:panelGrid>
        </h:panelGrid>

        <p:remoteCommand name="rc" update="panel" />


但是当我在“refereshButton”中使用“update”属性时,选择列表不会得到更新

下面是相同的代码,但没有p:remoteCommand,并且在refereshButton中具有update属性

        <h:panelGrid columns="1">
            <p:panel id="panel" header="Units"
                style="margin-bottom:10px; background:#F3F2F2; margin-bottom:0px">

                <p:pickList id="pickList"
                    value="#{AdminController.unitsPickListAll}" var="selectedUnit"
                    itemLabel="#{selectedUnit}" itemValue="#{selectedUnit}" />

            </p:panel>

            <h:panelGrid columns="1" styleClass="right-alignment">
                <h:panelGroup>
                    <p:commandButton id="refereshButton" value="#{i18n.refresh}"
                        immediate="true" action="#{AdminController.getAllUnits}"
                        update="pickList" />
                    <h:outputText value="&#160;&#160;" />
                    <p:commandButton id="saveButton" value="#{i18n.save}"
                        action="#{AdminController.updateUsedUnits}" />
                        
                </h:panelGroup>
            </h:panelGrid>
        </h:panelGrid>


这种行为背后的原因是什么?

您得到不同结果的原因是因为您正在进行不同的更新。通过远程命令和按钮更新
面板


使用按钮上的
update=“panel”
可获得相同的结果。这也将为您节省一个Ajax请求(和一些服务器负载)。

我尝试了这两种方法,从commandbutton更新面板,从remoteCommand更新pickList,第一种方法不起作用,第二种方法起作用。不,在按钮上使用
update=“panel”