This is used to display the element that enables the user to select only one among the list of available options. In the menu only one option is displayed at a time. This tag renders an html "select" element of size "1" with no multiple attribute. So have a look on the difference between listbox and menu. listbox can be specified of any size but menu is set to size "1" by default.
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:selectOneMenu example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body >
<h:form><center>
<t:outputText value="Choose any one from the list ahead :"/>
<t:selectOneMenu id="som" value="SI" >
<f:selectItem id="si1" itemLabel="Samsung" itemValue="sa" />
<f:selectItem id="si2" itemLabel="Logitech" itemValue="lo" />
<f:selectItem id="si3" itemLabel="LG" itemValue="lg" />
<f:selectItem id="si4" itemLabel="BenQ" itemValue="bq" />
</t:selectOneMenu>
</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:selectOneMenu 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/selectOneMenu.jsf"
enctype="application/x-www-form-urlencoded">
<center>
Choose any one from the list ahead :
<select id="_idJsp0:som" name="_idJsp0:som" size="1">
<option value="sa">Samsung</option>
<option value="lo">Logitech</option>
<option value="lg">LG</option>
<option value="bq">BenQ</option>
</select>
</center>
<input type="hidden" name="_idJsp0_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmEub
GFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQAGC9wYWdlcy9zZWx
lY3RPbmVNZW51LmpzcA==" /></form>
<!-- MYFACES JAVASCRIPT -->
</body>
</html>
|
This tag contains attributes given below :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Tomahawk selectOneMenu tag
Post your Comment