tags:

views:

150

answers:

2

Hi,

I have a h:selectOneRadio tag for displaying a number of radiobuttons:

<h:selectOneRadio value="#{myBean.radioButtonSelection}">
  <s:selectItems value="#{myBean.getPossibleRadioButtonSelections()}" var="rs" label="#{rs.toString}"/>                             
</h:selectOneRadio>

Now, instead of radiobuttons with string values (labels), I would like to have radio buttons with (clickable) images next to it. Is this possible? If so, how?

Update: Actually, there should be both text, and an image with a question mark which shows a modal panel when clicked on it.

A: 

Your best and most clean bet would be using CSS background images. Alternatively, you can also set itemLabelEscaped="false" and use plain vanilla HTML <img> in item label.

BalusC
clickable CSS background images?I actually need some <h:graphicImage>s, so I can show a modal panel when someone clicks on them. I don't think that would be possible with a background image.
Fortega
Then go for HTML.
BalusC
+1  A: 

You can use <h:outputLabel for="form:radioGroupId:X"> and place a <h:graphicImage> inside. (X is the number of the option)

Of course you would have to have two collections - one with the items, and one with the pictures, and iterate them separately - one with <s:selectItems> and the other with <ui:repeat>. A little tedious.

Bozho
How would you align this with `s:selectItems`?
BalusC
using `ui:repeat`, i.e. manually.
Bozho
I did something similar to your solution. The h:selectOneRadio creates a table, so I created a second table next to it (using <a:repeat>), containing the images... This works and looks fine, although the generated html code does not look very nice...
Fortega