How to change an image using commandButton in Java Primefaces?

Asked

Viewed 81 times

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 assemble a commandButton that when clicked, it triggers a function that will return if the house selected by the user is empty or if not, which ship is allocated there and then it subtiates the image that has in this commandButton by the image of the ship.

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

The biggest difficulty would be in this exchange of an image for another if someone can give a little help :)

1 answer

1


You will have to use the EL (Expression Language) of the first faces 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%"/>

Browser other questions tagged

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