Disa
Disa

Reputation: 45

Is there any way to call a method with h:commandButton without reloading page?

<h:commandButton value="A"   action="#{juegoService.ingresarPalabra('A')}">

</h:commandButton>

I'm using JSF 2.0, and I have a button like the above, for each letter of the alphabet that call a method that load an image on the page, depending the word you press will load the corresponding image, but I need to call the method without reloading the page because I can only have loaded one image on the page, because when I click other the page reloads the Bean and the other image returns to the first state thats its not charged.

Upvotes: 1

Views: 1225

Answers (1)

robson
robson

Reputation: 1673

You should use f:ajax and refresh container with image.

    <h:commandButton value="A with AJAX" id="button" action="#{juegoService.ingresarPalabra('A')}" >
      <f:ajax execute="@this" render="containerId" />
    </h:commandButton>

Upvotes: 1

Related Questions