O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using the SelectOneRadio component

Let us see how to use the <p:selectOneRadio> component, by performing the following steps:

  1. Create a form with <p:selectOneRadio> components:
    <h:form id="form" style="width: 500px; margin: 0 auto;">  
        <p:panel header="SelectOneRadio">
        <h:panelGrid columns="2" style="margin-bottom:5px" cellpadding="2">  
    
            <h:outputText value="Gender: " />  
            <p:selectOneRadio id="gender" value="#{selectionController.gender}">  
                <f:selectItem itemLabel="Male" itemValue="M" />  
                <f:selectItem itemLabel="Female" itemValue="F" />  
            </p:selectOneRadio>  
    
            <h:outputText value="Favourite Server: " />  
            <p:selectOneRadio id="server" value="#{selectionController.selectedServer}" layout="pageDirection">  
     <f:selectItems value="#{selectionController.servers}"/> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required