PrimeFaces Editor not updating value

1.6k Views Asked by At

I have this editor.xhtml where I have editor and a bunch of buttons and confirmdialogs for said buttons. All of this can be used in dialogs in my web application.

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>

The CustomEditorBean has a save method which is called. That method works correclty since it was working before I added the confirmDialog to this editor.xhtml. Now, if I write something on the editor, the value of the editor is not updated in the backing bean. So when I save, it will just save the old value of the editor, not the value I just wrote in the editor before clicking Save button. Any ideas how to fix this?

1

There are 1 best solutions below

2
On

Ok, I managed to solve it...

The reason for the problem: saveButton that opens the dialog was of type="button". When changed to "submit" the saving worked in the dialog.

Now, could someone tell me WHY ON EARTH IS THE TYPE BUTTON NOT WORKING IN THIS CASE!? I wasted a whole day for this.