File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Single radio button group for all rows in the rich:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Single radio button group for all rows in the rich:dataTable" Watch "Single radio button group for all rows in the rich:dataTable" New topic
Author

Single radio button group for all rows in the rich:dataTable

Josh Yuan
Greenhorn

Joined: Mar 03, 2011
Posts: 2
I have a rich:dataTable listing data rows with a radio button for each row, but these radio buttons should belong to a single radio button group so only one row can be selected from these radio buttons. However, when I use the following code, the radio button for each row belongs to its own radio button group, please help figure out some approach to have all rows' radio buttons belong to a single radio button group. Thanks.

<rich:dataTable id="linesId" var="line" value="#{dataTableAction.lines}"
rowClasses="rowLight, rowDark" headerClass="tableHeader" styleClass="table" columnClasses="tableColumn"
cellpadding="0" cellspacing="0" border="0" width="100%">
<h:column>
<f:facet name="header">
<hutputText value="Select" />
</f:facet>
<h:selectOneRadio id="lineRadio" layout="lineDirection">
<f:selectItem itemValue="#{line.selected}" itemLabel="">
</f:selectItem>
</h:selectOneRadio>
</h:column>
<h:column>
<f:facet name="header">
Name
</f:facet>
<hutputText value="#{line.name}" size="25" rendered="#{line.existing}" styleClass="tableOutput"/>
</h:column>
</rich:dataTable>
Max Katz
Ranch Hand

Joined: Aug 03, 2009
Posts: 72
That's just how JSF works, every row is its own group.
You can use JavaScript, first go over all the radio buttons and uncheck them and then check the newly selected.


Blog: http://mkblog.exadel.com
HTML Prototypes: http://gotiggr.com
rashmi coorg
Greenhorn

Joined: Jul 11, 2011
Posts: 17
hi.. did you get a solution for this? even i am facing a similar problem.. kindly post the solution if you have solved it..
 
IntelliJ Java IDE
 
subject: Single radio button group for all rows in the rich:dataTable
 
Threads others viewed
Doubt in JSF
JSF page submitting to backing bean, even javascript validation fails...
Datatable column header issue
how to select a row datatable
empty table column header on a dataTable when trying to fill it dynamically...
IntelliJ Java IDE