Primefaces, button requires two clicks to perform action

Asked

Viewed 1,597 times

3

While executing the code below, I have to double click on 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>
  • I had the same problem, what I had to do was put a global="false" on the button, so it does not let ajaxStatus activate before its activation. In my case, ajaxStatus was updating a field before executing the button.

2 answers

3

You are using ajax=false along with update, and that is wrong.

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

  • tried both ways and the problem persists

  • 1

    Exchange the update for 'Tablepais'

1

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

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

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

Method of class Beanpais:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.