radio buttons inside datatable

View: New views
1 Messages — Rating Filter:   Alert me  

radio buttons inside datatable

by terry.human :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I have a problem using radio buttons inside a datatable.

I have in my backing bean:

private Integer id;     //For radio button component value
private int selectedRowId = -1;   // For  radio button item value, also used as selected row ID.
private TableRow selectedRow;  // For table row data.


        public void handleRadio1ValueChange(ValueChangeEvent valueChangedEvent) {
                selectedRowId = getTable1().getRowIndex();
                     selectedRow = (TableRow)getTable1().getRowData();
        }

            public void onAceptarClick(){
                         System.out.println("The value of selectedRowId is "+selectedRowId);
            }
       
and in the jsp:
<hx:dataTableEx....>
<hx:selectOneRadio id="radio1"
        disabledClass="selectOneRadio_Disabled"
        styleClass="selectOneRadio"          valueChangeListener="#{pc_RowSelectRadioButtonInDataTableView.handleRadio1ValueChange}              onclick="return radiobuttonClick(this, event);" value="#{pc_RowSelectRadioButtonInDataTableView.id}"
onchange="submit()">
                                                                                        <f:selectItem itemValue="#{pc_RowSelectRadioButtonInDataTableView.selectedRowId}" />

</h:selectOneRadio>
</dataTable>

When the user click on a radiobutton and then click on "aceptar" I get well the value of selectedRowId the firt time, but if the user click in other radiobutton and then click on "aceptar" I get a wrong value of selectedRowId (I get "-1")

Could you help me?

Thanks.