How to change an image using the commandButton in Java PrimeFaces?

0

Good afternoon, I'm developing a naval battle game in JAVA using Primefaces to make the front end. I would like a help to mount a commandButton that when clicked, trigger a function that will return if the house selected by the user is empty or if not, which ship is allocated there and then replace the image that has in that commandButton by the image of the ship.

<h:commandButton image="/resources/images/agua.png" style="width:100%"/>

The biggest difficulty would be to exchange one image for another if someone can help:

    
asked by anonymous 16.06.2018 / 22:39

1 answer

1

You will have to use the EL (Expression Language) of the primefaces in the frontend.

You probably have a class called NavioBean this class has an attribute called imagem (or img , whatever the name)

<h:commandButton image="#{navioBean.imagem}" style="width:100%"/>
    
16.06.2018 / 23:29