Tomahawk radio tag

This component is used when selectOneRadio component takes the value "spread" for "layout" attribute.

Tomahawk radio tag

Tomahawk radio tag

        

This component is used when selectOneRadio component takes the value "spread" for "layout" attribute. Using this tag we can position the radio button anywhere in the document. Its "for" attribute is used to specify the id for selectOneRadio component and "index" attribute is used to specify which selectItem value is to be displayed. Here "0" value for index attribute is used to select the first selectItem value. This all can be understood from the following example:

Code Description : 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>t:radio example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body >
<h:form><center>
<t:selectOneRadio id="sor" value="SI" layout="spread"
border="1"
style="font-weight:bold;
background-color:#99CCFF;">
<f:selectItem id="si1" itemLabel="Samsung" itemValue="sa" />
<f:selectItem id="si2" itemLabel="Link" itemValue="lo" />
<f:selectItem id="si3" itemLabel="Logitech" itemValue="lg" />
<f:selectItem id="si4" itemLabel="BenQ" itemValue="bq" /> 
</t:selectOneRadio>

<t:panelGrid columns="1" width="20%" style="color:green;"
cellpadding="0" cellspacing="5">

<t:panelGroup>
<t:radio for="sor" index="0"></t:radio>
<t:inputText />
</t:panelGroup>
<f:verbatim><hr></f:verbatim>
<t:panelGroup>
<t:radio for="sor" index="1"></t:radio>
<t:inputText />
</t:panelGroup>
<f:verbatim><hr></f:verbatim>

<t:panelGroup>
<t:radio for="sor" index="2"></t:radio>
<t:inputText />
</t:panelGroup>
<f:verbatim><hr></f:verbatim>

<t:panelGroup>
<t:radio for="sor" index="3"></t:radio>
<t:inputText />
</t:panelGroup>

</t:panelGrid>
</center></h:form>
</body>
</html>
</f:view>

Rendered Output :

 Html Source Code :

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
          charset=iso-8859-1">
    <title>t:radio example</title>
    <style type="text/css">
     <!--
       body{
         background-color:#fff2f2;
         margin-top:30;
       }
    -->
    </style>
  </head>
  <body >
     <form id="_idJsp0" name="_idJsp0" method="post"
           action="/tomahawk_tags/pages/radio.jsf"
           enctype="application/x-www-form-urlencoded">
      <center>
	<table cellpadding="0" cellspacing="5" width="20%"
               style="color:green;">
          <tbody>
            <tr>
              <td>
                <label>
                   <input type="radio" name="_idJsp0:sor" 
                          value="sa"
                          style="font-weight:bold;
                          background-color:#99CCFF;" />
                   &#160;Samsung
                </label>
                <input id="_idJsp0:_idJsp4" 
                       name="_idJsp0:_idJsp4"
                       type="text" value="" />
              </td>
            </tr>
            <tr>
              <td><hr></td>
            </tr>
            <tr>
              <td>
                <label>
                   <input type="radio" name="_idJsp0:sor"
                          value="lo"
                          style="font-weight:bold;
                          background-color:#99CCFF;" />
                  &#160;Link
                </label>
                <input id="_idJsp0:_idJsp8"
                       name="_idJsp0:_idJsp8"
                       type="text" value="" />
              </td>
            </tr>
            <tr>
              <td><hr></td>
            </tr>
            <tr>
              <td>
                 <label>
                   <input type="radio" name="_idJsp0:sor"
                          value="lg"
                          style="font-weight:bold;
                          background-color:#99CCFF;" />
                   &#160;Logitech
                </label>
                <input id="_idJsp0:_idJsp12"
                       name="_idJsp0:_idJsp12"
                       type="text" value="" />
              </td>
            </tr>
            <tr>
              <td><hr></td>
            </tr>
            <tr>
              <td>
                <label>
                   <input type="radio" name="_idJsp0:sor"
                          value="bq"
                          style="font-weight:bold;
                          background-color:#99CCFF;" />
                   &#160;BenQ
                </label>
                <input id="_idJsp0:_idJsp16"
                       name="_idJsp0:_idJsp16"
                       type="text" value="" />
              </td>
            </tr>
          </tbody>
       </table>
</center>
<input type="hidden" name="_idJsp0_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState" 
       id="javax.faces.ViewState" 
       value="rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5Ynx
BzKWwCAAB4cAAAAAN0AAMxODdwdAAQL3BhZ2VzL3JhZGlvLmpzcA==" />
</form>
<!-- MYFACES JAVASCRIPT -->
</body>
</html>

This tag contains attributes given below :

  • id : This is the value which is used to uniquely identify the component within the closest container like form or subview. The main thing to remember is that its value must be a static value.
  • binding : This attribute is used to specify the property of the backing bean with which this component instance is to be bound.
  • rendered : Its default value is true. If  this attribute is set to true then this component is presented in the page to the user. If false, then this component is not rendered.
  • enabledOnUserRole : If the current user has one of the roles listed in the enabledOnUserRole attribute then enabling or disabling of the component is decided on the base of "disabled" attribute. If disabled attribute is set to true then component is disabled otherwise enabled. If the user is not in the above list then the component is rendered disabled.
  • visibleOnUserRole : If the current user has one of the roles listed in the visibleOnUserRole attribute then processing of the component is decided on the base of "rendered" attribute. If the rendered attribute is set to true then component is not rendered otherwise displayed  on the page. On the other hand if the current user is not in the above list then the component is not processed.
  • for : This attribute takes the id of the referenced selectOneRadio component.
  • index : This attribute is used to reference the corresponding selectItem where "0" is used to reference the first selectItem and so on.