Reputation: 16900
I am trying to create a grooup of h:selectOneRadio but ui:repeat gives it different id for each row. This is my code :-
<ui:repeat id="themes" value="#{RegisterBean.objBlogTemplateList}" var="item">
<p:graphicImage alt="#{item.templatePicName}" style="border: solid 5px white;width: 200px;height: 200px;" value="#{app:getCommonImagePath(item.templatePicName)}"/>
<h:selectOneRadio rendered="false" value="#{RegisterBean.blogTemplateId}" layout="lineDirection" id = "rdTemplateId">
<f:selectItem itemLabel="#{item.templateName}" itemValue="#{item.templateId}"/>
</h:selectOneRadio>
</ui:repeat>
Actually i want to create a single radio button with different selectItems in it which should be from the rows of my table in database. How do i do this?
Upvotes: 2
Views: 6671
Reputation: 11540
You won't be able to do this with a JSF component out-of-the-box. However it's fairly easy to implement a custom renderer to accomplish what you're after. I would suggest dumping an image URL into the SelectItem description field as this is almost never used. Then in your renderer just place this value into an IMG tag.
I've written a little about a custom renderer for selectboxes here - should be an identical process for you.
Upvotes: 1
Reputation: 1108632
It more sounds like that you rather need <f:selectItems>
.
<h:dataTable value="#{bean.items}" var="#{item}">
<h:column>
<h:selectOneRadio value="#{item.selectedTemplate}">
<f:selectItems value="#{bean.availableTemplates}" />
</h:selectOneRadio>
</h:column>
...
You can feed it with a SelectItem[]
, List<SelectItem>
or a Map<Object, String>
.
Upvotes: 1
Reputation: 597026
<t:selectOneRadio>
supports layout="spread"
so that you can spread the individual option buttons from a single group.
Upvotes: 0