开发者

How to read the value of the radio button

开发者 https://www.devze.com 2022-12-20 18:00 出处:网络
I would like to read the selected role information on form submit (a role is selected for a user from a list of roles). How do I read the selected radio button value in my EntityHome interface (Note:

I would like to read the selected role information on form submit (a role is selected for a user from a list of roles). How do I read the selected radio button value in my EntityHome interface (Note: I didn't want to use the h:selectOneRadio option here)

                                <tr>
                                    <s:div rendered="#{userHome.instance.type ne 'admin'}">
                                        <th width="150" class="rich-table-subheadercell center">#{_user.getName()}</th>
                                    </s:div>


                                    <c:forEach items="#{userHome.instance.roles}" var="_role">
                        开发者_开发问答                <td width="150" class="center" style="background: rgb(100, 100, 100) none repeat scroll 0% 0%;">
                                            #{_role.name}
                                            <input type="radio" style="display : none" name="#{userHome.instance.id}" value="#{_role.id}"/>
                                        </td>
                                    </c:forEach>
                                </tr>


Two comments.

First of all. Use JSF Components where you can.

Secondly. Avoid using JSTL tags. Remove the c:forEach if you don't have to use it. Replace it with ui:repeat, h:dataTable etc.

Now to answer your question for a workaround if you can't directly use h:selectOneRadio

What you will have to do is use @WebRemote in Seam, and then by using javascript you can on form submit, set the value through Ajax in your UserHome component.

Take a look at chapter 5. Remoting in the Seam Documentation for more information on how to use Remoting.


You need to point the value / list to an ArrayList of SelectItem there's where the items you selected will be stored.

0

精彩评论

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

关注公众号