Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
JSF
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Tomahawk selectOneRadio tag

                          

This tag is used to create radio buttons on the page. It renders html input tag with type "radio". It contains all the features of standard jsf radio component. It's layout attribute can take different values for layout of radio buttons. If this is set to "spread" value then it doesn't display html but provides feature to display radio buttons according to the developer's need. For this radio tag is used. This feature has been exposed in the example below in this tutorial.

Code Description : In this code, the index attribute is to identify the item to select for display.  

 

 

 

 

 

 

 

<%@ 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:selectOneRadio 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="2" dir="ltr" width="40%" style="color:green;" >
    <t:radio for="sor" index="0"></t:radio>
    <t:radio for="sor" index="1"></t:radio>
  </t:panelGrid>
  <hr>
  <t:panelGrid columns="2" dir="ltr" width="40%" style="color:green;" >
    <t:radio for="sor" index="2"></t:radio>				
    <t:radio for="sor" index="3"></t:radio>
  </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:selectOneRadio 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/selectOneRadio.jsf"
enctype="application/x-www-form-urlencoded"><center>
<table width="40%" dir="ltr" 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></td><td><label><input type="radio" 
   name="_idJsp0:sor" value="lo" style="font-weight:bold; 
   background-color:#99CCFF;" />&#160;Link
</label></td></tr></tbody>
</table>
<hr>
<table width="40%" dir="ltr" style="color:green;">
<tbody><tr><td><label>
  <input type="radio" name="_idJsp0:sor" value="lg" 
  style="font-weight:bold; background-color:#99CCFF;" />
  &#160;Logitech</label></td><td><label>
  <input type="radio" name="_idJsp0:sor" value="bq" 
  style="font-weight:bold; background-color:#99CCFF;" />
  &#160;BenQ
</label></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="rO0ABXVyABNbTGphdmEubGFuZy5PYm
plY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAEzcHQAGS9wYWdlcy9zZWxlY3RPbmVSYW
Rpby5qc3A=" /></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.
  • value : The initial value of the component is set to this attribute.
  • converter : This attribute is used to specify the converter for the component.
  • immediate : This attribute is a boolean attribute that is used to identify the phase during which the value change event should be fired. In normal processing of the event, if immediate attribute is not set to true, the value change event is fired during the invoke application phase but if immediate attribute is set to true then the event is fired at the end of apply request value phase.
  • required : This is a boolean attribute. If it is set to true then it is necessary for the component to have the value otherwise an error message is rendered to the user for the component.  
  • validator : It takes the method binding expression. This expression represents the validator method. This method is called at the time of validation of the component. 
  • valueChangeListener : This also takes a method binding expression. This expression represents value change listener method. This method will be called when new value is set for this component. you can change the phase of the life cycle when this method should be fired by the use of immediate attribute discussed above.
  • dir : It is used to set the direction of the text to be displayed. It can take two values LTR(left to right) and RTL (right to left). 
  • lang : It is used to set the base language of the component when displayed.
  • style : It is used to set the CSS style definition for the component.
  • title : It is the standard html attribute. It is used to set the tooltip text for this component.
  • styleClass : It is used to set the CSS class for the component. It is same as html class attribute.
  • onclick : Script to be invoked when the element is clicked. 
  • ondblclick : It is used for Java Script code to be invoked when the element is double-clicked. 
  • onmousedown : It is used for Java Script code to be invoked when the pointing device is pressed over this element. 
  • onmouseup : It is used for Java Script code to be invoked when the pointing device is released over this element. 
  • onmouseover : It is used for Java Script code to be invoked when the pointing device is moved into this element. 
  • onmousemove : It is used for Java Script code to be invoked when the pointing device is moved while it is in this element. 
  • onmouseout : It is used for Java Script code to be invoked when the pointing device is moved out of this element. 
  • onkeypress : It is used for Java Script code to be invoked when a key is pressed over this element. 
  • onkeydown : It is used for Java Script code to be invoked when a key is pressed down over this element.
  • onkeyup : It is used for Java Script code to be invoked when a key is released over this element. 
  • accesskey : This is standard html attribute. It is used to set the access key for the element which is used to send the focus to the element when pressed. 
  • alt : This is used as an alternate text that is displayed when browser is not able to display the element.
  • disabled : Its a boolean attribute. This is used to disable the element to receive focus, when it is set to true. 
  • onblur : This attribute sets JavaScript code to execute when the component loses the focus.
  • onfocus : This attribute sets JavaScript code to execute when the component receives the focus.
  • onchange : This attribute sets JavaScript code to execute when the element is modified.
  • onselect : This attribute sets JavaScript code to execute when the element is selected.
  • readonly : Its a boolean attribute. It is used to indicate the user that its value can't be modified, if it is set to true. 
  • tabindex : This is a standard html attribute. It is used to set the order of receiving the focus on the movement of TAB key by the user. 
  • escape : This attribute specifies whether the rendered markup should be escaped.
  • 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.
  • forceId : This is a boolean attribute with default value false. If this attribute is set to true, the tag is forced to render the id for the component exactly as mentioned in the id attribute of the tag. The benefit of this attribute is that we can reference component by id in the javascript. If we don't use this attribute with the true value then the id for the component is presented in different format.
  • forceIdIndex : This is a boolean attribute with default value true. If this value is true then the the component displays the index number in its id value if the component is in a list. If this attribute is set to false then this component will not append index number as suffix . If forcrId is set to false then its value is ignored.
  • displayValueOnly : This is boolean attribute with the default value false. If this value is set to true then only the value of the component is rendered not the widget of the component.
  • displayValueOnlyStyle : This attribute is used to specify the style used when displayValueOnly is true.
  • displayValueOnlyStyleClass : This attribute is used to specify the style class used when displayValueOnly is true.
  • layout : This attribute is used to set the layout of the component. It can take values "pageDirection" for vertical layout, "lineDirection" for horizontal layout, "spread" for developer placement. The default value for this tag is lineDirection. If we set this attribute to spread then it is not rendered and developer uses radio tags to place radio buttons.
  • border : This attribute is used for the width of the border.

                          

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
spring hibernate web e
command line argument
encoding
sÑ??д?Ñ??и??Ñ??д?Ñ?
where to keep backgro
sum of array
value change listener
how to user JSpinner t
download api struts
clear
jsp login by insertin
multiple rows in singl
disable minimize butto
reading a CSV file in
tree view
factorial no.java scri
sound file to wav form
reading a text file
jsp bank examples
Struts2 Hibernate
jsp MENU SELECT MAKES
architecher of struts
java excel
jsp MENU SELECT CREATE
Javascript Date and Ti
scrollbar with event
Combattons la programm
data input stream
CREATION OF JAVA BEAN
lentgh of character in
runnable
JComboBox data
move file
Solaris 10 OS Released
FlowLayout
MULTIPLE SELECT COMBO
Create table and inser
Multiple try catch
number format struts 2
html:form
columns in table
loop
Example below send any
Linux Caixa Mâ?¨â??
hash table
JComboBox
Connection Pooling cod
ImageReaderServlet
Applet event button
DOM
delete data in mysql d
jsp bean
��?��?
reading and writing ex
Metatag
Combattons la programm
java date picker
view the result of jme
count word
read/write text file u
Ñ?Ð???Ñ?Ð??Ñ?Ð?Ð?Ñ?Ð??
create xml using java
à¹?à¸?à¸???à¹?à¸?à¸?à¹
date picker
FORM VALIDATION IN JAV
jsp programs with mapp
breakà¹?à¸?à¸?à¹?à¸??à
Adding multithreading
select box struts12
Passing Parameters in
Linux Caixa MÑ??иÑ???
grant chart
jdbc mysql connection
populate dropdown in j
deploy a JSP and servl
finding max min array
sample examples in spr
login jsp
scroll bar
File Validation code
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.