Skip to content Skip to sidebar Skip to footer

How To Get Selected Icefaces Datatable Row Using Radiobutton?

How can I select a row in icefaces datatable using radio button? I tried with the following

Solution 1:

You should use the ice:selectOneRadio with spread layout:

<ice:selectOneRadio id="myRadioId" layout="spread" ... /> 
<ice:dataTable ... >
    <ice:column ...>
        <ice:radio for="myRadioId" ... />
    </ice:column>
    ...
</ice:dataTable>

Solution 2:

Here's how the generated HTML of each radio button look like:

<table id="crud:tab_cr:9:_id53" border="0" onkeypress="dataTableSelectOneRadio(this);">
  <tr>
    <td>
      <input type="radio" name="crud:tab_cr:9:_id53" id="crud:tab_cr:9:_id53:_1" value="null" onkeypress="dataTableSelectOneRadio(this);Ice.util.radioCheckboxEnter(form,this,event);" />
      <label for="crud:tab_cr:9:_id53:_1">null</label>
    </td>
  </tr>
</table>

So IceFaces is apparently rendering a whole HTML table around the radio button and putting the JS function on the <table> as well. The JS function clearly doesn't belong there at all (apart from the fact that onkeypress is incorrect, it should be onclick).

The <h:selectOneRadio> doesn't render a whole table around by default. This can only mean that you were actually using <ice:selectOneRadio> or that the IceFaces replaced the standard renderer for <h:selectOneRadio>. You need to fix it in this corner. Either replace by <h:selectOneRadio> or report a bug to IceFaces guys that their radio renderer is incorrectly putting the JS function on <table> element as well.


Post a Comment for "How To Get Selected Icefaces Datatable Row Using Radiobutton?"