JSF SelectOneRadio Example

The JSF SelectOneRadio component displays a radio buttons in the browser. It allows user to select one value at a time. The <h:SelectOneRadio> renders the HTML table component with collection of <input type=”radio” /> buttons. Below is JSF and its corresponding HTML tag


JSF <h:SelectOneRadio>:



<f:selectItem itemLabel=“Blue” itemValue=“Blue” />

<f:selectItem itemLabel=“Green” itemValue=“Green” />

<f:selectItem itemLabel=“Red” itemValue=“Red” />



HTML Table with collection of Input elements:



<tr> <td>

<input type=”radio” name=”j_idt2:j_idt3″ id=”j_idt2:j_idt3:0″ value=”Blue” /><label for=”j_idt2:j_idt3:0″> Blue</label>

</td> <td>

<input type=”radio” name=”j_idt2:j_idt3″ id=”j_idt2:j_idt3:1″ value=”Green” /><label for=”j_idt2:j_idt3:1″> Green</label>

</td> <td>

<input type=”radio” name=”j_idt2:j_idt3″ id=”j_idt2:j_idt3:2″ value=”Red” /><label for=”j_idt2:j_idt3:2″> Red</label>

</td> </tr>



JSF SelectOneRadio Example:

The below JSF page has a <h:SelectOneRadio> component where the value is bound to the backing bean class. The console prints the selected value when a user selects a radio button and hits the submit button in the browser.




Below is the backing bean class




Below is how the <h:SelectOneRadio> looks like in the browser. Below, I selected Blue and hit the Submit button. The server console prints the value ‘Selected Value = Blue’


112717_0431_JSFSelectOn1 JSF SelectOneRadio Example

Download the Project:


govindan JSF SelectOneRadio Example
Connect me


Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
govindan JSF SelectOneRadio Example
Connect me
By | 2017-11-26T23:39:08+00:00 November 26th, 2017|Categories: JSF|Tags: , , , , , |0 Comments
Like us on Facebook.