开发者

How do i create a group of h:selectOneRadio in JSF?

开发者 https://www.devze.com 2022-12-27 17:29 出处:网络
I am trying to create a grooup of h:selectOneRadio but ui:repeat gives it different id for each row. This is my code :-

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?


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.


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>.


<t:selectOneRadio> supports layout="spread" so that you can spread the individual option buttons from a single group.

0

精彩评论

暂无评论...
验证码 换一张
取 消