Primefaces 3.5 selectOneRadio with image as background doesn't work

1k Views Asked by At

I want to show selectOneRadio with images above every radio button. I read that best solution set style as background image for every radio button

<p:selectOneRadio value="#{adminManageBroadcastController.selectedImage}" converter="#{broadcastImageConverter}">
                    <f:selectItems value="#{adminManageBroadcastController.fileUploadList}"  var="image"
                                   itemValue="#{image}"
                                   style="background:url(#{image.url}); no-repeat !important;"/>
                </p:selectOneRadio> 

I know that data inside fileUploadList is correct. But instead of label I see hashCode (equals and hashcode were override). If I do that I haven't problem

 itemLabel="&lt;img src=&quot;#{image.url}&quot; width=&quot;20&quot; height=&quot;20&quot; alt=&quot;broadcast_img&quot;&gt;"
itemLabelEscaped="false"

Why image isn't display as label?

1

There are 1 best solutions below

1
On

You are setting your image as a selectItem. That is not what you want. The selectItem should be something like an object with (id, desc) values. The image goes into p:graphicImage.

Maybe p:selectOneListbox is what you are looking for. ;)