javaajaxprimefacesliferaycommandbutton

primefaces commandbutton ajax submit works as a non-ajax submit


I'm using primefaces 3.5 and I want to update de value of an object using p:commandButton with ajax, but when I click on the p:commandButton the form submits entirely as a non-ajax submit. I tried with immediate=true, ajax="true" (but I read that this option is the default) partial-submit="true" but nothing, the button refresh all the page instead of just the asignarUA component.

Note: this is a liferay (6.2 CE) portlet.

This is part of the code:

<html xmlns="http://www.w3.org/1999/xhtml"  
xmlns:h="http://java.sun.com/jsf/html"  
xmlns:f="http://java.sun.com/jsf/core"  
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form>
    <p:commandButton onclick="asignarUADlg.show()" update=":asignarUA" title="Asignar" value="Asignar">
    <f:setPropertyActionListener value="#{solicitud }" target="#{mailboxView.solicitud}"/>
    </p:commandButton>                                                
</h:form>


<p:dialog id="asignarUA" widgetVar="asignarUADlg" modal="true" header="Asignar Unidades Administrativas" width="530" showEffect="fade" hideEffect="fade">
    <h:form enctype="multipart/form-data">
        <h:outputLabel for="dependencia" value="Dependencia: " />
        <h:outputText value="#{mailboxView.solicitud.nombreDependencia}" rendered="#{not empty mailboxView.solicitud}" />
        <p:separator />

        <p:commandButton value="Enviar" ajax="false" actionListener="#{mailboxView.asignar}" update=":messages2"/>
        <p:commandButton value="Cancelar" onclick="asignarUADlg.hide()" type="button"/>
    </h:form>
</p:dialog>
</h:body>
</html>

Solution

  • I had to upgrade my PrimeFaces version to 5.3 and it works. The only thing that I had to change was the process attribute:

    <p:commandButton process="@this :dialogContent" update=":dialogContent" onclick="PF('asignarUADlg').show()" title="Asignar" value="Asignar">
        <f:setPropertyActionListener value="#{solicitud }" target="#{mailboxView.solicitud}"/>
    </p:commandButton>