【问题标题】:PrimeFaces Editor not updating value [duplicate]PrimeFaces 编辑器不更新值 [重复]
【发布时间】:2016-10-18 23:12:19
【问题描述】:

我有这个 editor.xhtml,其中有编辑器和一堆按钮以及用于所述按钮的确认对话框。所有这些都可以在我的 Web 应用程序的对话框中使用。

editor.xhtml:

<ui:composition
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">

        <p:confirmDialog widgetVar="saveDialog" appendTo="@(body)" showEffect="fade" hideEffect="fade"
                          message="Do you want to save the content?" icon="ui-icon-disk" severity="info" closable="true" >
            <p:commandButton value="Yes" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" action="#{customEditorBean.save}" oncomplete="PF('saveDialog').hide()"  />
            <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" onclick="PF('saveDialog').hide()" />
        </p:confirmDialog>

        <h:form>
            <span id="editorWidgetVarId">
                <p:editor widgetVar="editorWidget" onchange="rc()" value="#{customEditorBean.sisalto}" width="600" maxlength="8000" />
            </span>
            <p:remoteCommand delay="700" name="rc" actionListener="#{customEditorBean.noticeChange}" process="@this" update="saveButton"/>

            <p:commandButton id="saveButton"  onclick="PF('saveDialog').show()" value="Save" rendered="#{customEditorBean.canSave}"
            disabled="#{!customEditorBean.saveEnabled}" type="button">
            </p:commandButton>
        </h:form>

</ui:composition>

CustomEditorBean 有一个被调用的保存方法。该方法工作正常,因为在我将 confirmDialog 添加到此 editor.xhtml 之前它正在工作。现在,如果我在编辑器上写一些东西,编辑器的值不会在支持 bean 中更新。所以当我保存时,它只会保存编辑器的旧值,而不是我在单击保存按钮之前在编辑器中写入的值。任何想法如何解决这个问题?

【问题讨论】:

    标签: jsf primefaces jsf-2.2 confirm-dialog


    【解决方案1】:

    好的,我设法解决了...

    问题的原因:打开对话框的 saveButton 是 type="button"。当更改为“提交”时,保存在对话框中起作用。

    现在,有人可以告诉我为什么在这种情况下类型按钮不起作用!?我为此浪费了一整天。

    【讨论】:

    • p:commandButton 不支持通过获取请求传递值,仅支持提交。无需定义类型,只需将其省略即可。默认使用提交。
    • 非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 2015-08-02
    • 2015-08-10
    • 1970-01-01
    • 2014-08-03
    • 1970-01-01
    • 2021-02-24
    相关资源
    最近更新 更多