En-Motion
En-Motion

Reputation: 919

Display image based on number value JSF

I have a number of details about a product which I wish to display. In my db the status of these items is stored as a number eg 1 - Worldwide, 2 - Europe Only, 3 - US Only

I currently use:

<h:outputText value="#{product.value}" />

Instead of the number I would like to display an image instead. What would be the best way to go about this?

Upvotes: 2

Views: 507

Answers (1)

BalusC
BalusC

Reputation: 1108722

Have images with filenames like status1.gif, status2.gif, status3.gif and display it as <h:graphicImage> with a "dynamic" filename as follows:

<h:graphicImage value="status#{product.value}.gif" />

Upvotes: 2

Related Questions