p:remoteCommand only update =“@ all”PF5

时间:2014-12-27 23:51:16

标签: spring jsf jsf-2 primefaces

在下面的代码<p:remoteCommand>上,当我使用 @all 时更新整个视图,但我尝试更新@this@form或{{1} } 没有成功。即使wizardEventContainer按我的意愿工作,我也希望只更新特定的容器@all

在PrimeFaces网站上,该示例使用id属性,因此我不知道为什么我也无法得到它。

我使用PF5,JSF 2.2和SWF 2.4。我将JSF分隔符更改为 - 而不是

wizardEventContainer

与JAVA方法链接的JS代码

<h:form id="formEditor" styleClass="eventEditorForm" prependId="true">
            <p:editor id="editorEvent" height="150" width="900" maxlength="500" onchange="writeTextonPanel()" widgetVar="editorWidget"  />

            <h:panelGroup layout="block" id="eventEditorButtons" styleClass="eventEditorButtons">
                <h:commandButton value="#{msg['saveLayer.btn']}" actionListener="#{eventProvider.saveTextLayer()}" alt="#{msg['saveLayer.btn.alt']}" title="#{msg['saveLayer.btn.title']}" onclick="showEditor('save')">
                    <f:ajax execute="@form" render="-formBotones-wizardEventContainer" />
                </h:commandButton>
                <h:commandButton value="#{msg['omitLayer.btn']}" alt="#{msg['omitLayer.btn.alt']}" title="#{msg['omitLayer.btn.title']}" onclick="showEditor('delete')">
                    <f:ajax execute="@form" render="-formBotones-wizardEventContainer" />
                </h:commandButton>
            </h:panelGroup>

            <h:inputHidden id="tempCSS" value="#{eventProvider.tempCSS}" />
            <h:inputHidden id="tempHTML" value="#{eventProvider.tempHTML}" />
</h:form>

<h:form id="formBotones" prependId="true">

    <p:remoteCommand name="omitTextLayer" process="@this" update="formBotones-wizardEventContainer" actionListener="#{eventProvider.omitTextLayer()}" />
    <p:remoteCommand name="modifyTextLayer" actionListener="#{eventProvider.modifyTextLayer()}" />
    <h:inputHidden id="tempCSSforModify" value="#{eventProvider.tempCSSModified}" />

    <h:panelGroup layout="block" id="wizardEventContainer" styleClass="wizardEventContainer">
        <h:inputHidden id="tempTextIdLayer" value="#{eventProvider.tempTextIdLayer}" />
    </h:panelGroup>
</h:form>

P.D :我编辑了添加完整代码示例和js代码,链接到p:remoteCommand上的java方法 谢谢!

1 个答案:

答案 0 :(得分:1)

如果从p:remoteCommad而不是p:commandButton抛出h:commandButton,则使用ID可以正常更新。

因此,代码必须更改为

<p:commandButton value="#{msg['omitLayer.btn']}" alt="#{msg['omitLayer.btn.alt']}" title="#{msg['omitLayer.btn.title']}" onclick="showEditor('delete')" />