Adriano_jvma
Adriano_jvma

Reputation: 475

p:ajax not working with p:commandButton

I try to do this but I never get it work ;why is that ajax not supported ??

<p:commandButton value="MAJ" rendered="#{LigneXL.resultat eq 'Pas de FMD'}" onclick="confirmation.show()"  >
    <f:setPropertyActionListener target="#{parserXls.selectitem}" value="#{LigneXL}" />                  
    <p:ajax event="click" listener="#{parserXls.listenercomposant()}"/>             
</p:commandButton> 

Listener is never executed Why !!! I'm trying to get another object according to selectitem

public void listenercomposant(){
    composantitem=ChercherComposant(selcetitem.getRefcomposant(), selcetitem.getReffabricant());
}

Upvotes: 5

Views: 23210

Answers (2)

Makky
Makky

Reputation: 17463

The p:commandButton is already natively ajax enabled. So there is no need to have a p:ajax inside and and you can just use

  <p:commandButton value="TestButton" actionListener="#{bean.saveSomething}" id="id"    
  update="panel" />

As you can see p:commandButton already has and actionListener so just use that.

Upvotes: 11

Adriano_jvma
Adriano_jvma

Reputation: 475

this is the solution I use action instead of listener

  <p:commandButton value="MAJ" rendered="#{LigneXL.resultat eq 'Pas de FMD'}" onclick="confirmation.show()" action="#{parserXls.listenercomposant()}" >
    <f:setPropertyActionListener target="#{parserXls.selcetitem}" value="#{LigneXL}" />                                            
    </p:commandButton> 

Upvotes: -2

Related Questions