Primefaces, button requires two clicks to perform action

3

When I execute the code below, I have to double-click the button so that the delete action happens, I saw many with similar problems, but no effective solution:

<h:form id="TablePais"  prependId="false" >
        <p:dataTable id="tbPais" var="pais" value="#{beanPais.listagem}"  emptyMessage="Não há registros">
            <p:column headerText="Ações">
                 <p:commandButton
                     id="deleteButton"
                     icon="ui-icon-trash"
                            actionListener="#{beanPais.excluir}"
                            update="tbPais"
                            ajax="false">
                        <f:setPropertyActionListener
                                value="#{pais}"
                                target="#{beanPais.selectedPais}"
                                />       
                    </p:commandButton>
            </p:column>
            <p:column headerText="Codigo">
                <h:outputText value="#{pais.cod}" />
            </p:column>

            <p:column headerText="Nome:">
                <h:outputText value="#{pais.nome}" />
            </p:column>
        </p:dataTable>
    </h:form>
    
asked by anonymous 01.04.2014 / 02:32

2 answers

3

You are using ajax = false together with update, and this is wrong.

Update is to be used with ajax = true or even need to write the ajax attribute.

    
01.04.2014 / 13:25
1

Good afternoon, could you try to use the process="@this" and partialSubmit="true" attribute? if the problem persists, try to test using the procedure as below:

Change your delete method to receive a parent object as a parameter to perform the deletion.

    <p:commandButton id="deleteButton" icon="ui-icon-trash" actionListener="#
{beanPais.excluir(pais)}" update="tbPais" ajax="true" process="@this" partialSubmit="true" />

BeanPais class method:

public void excluir(SeuObjetoPais pais){
   //... Procedimentos de exclusão levando em conta o parametro enviado.
}
    
02.04.2014 / 19:27