views:

150

answers:

2

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>
A: 

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

Filip Ekberg
Have you checked the code and read the question? How would you do this that way without `h:selectOneRadio`?
BalusC
I just pointed out that he need to use a List to store the values selected.
Filip Ekberg
This is just plain wrong. OP want's one value, thus you should point the value, in this case role to either `Role` or `String` and not `List` as you imply here. If there was a checkbox, then `List` would have been correct
Shervin
A: 

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.

Shervin