h:selectOneMenu – Java Server Faces (JSF)

  • Topic : Java Server Faces (JSF)
  • Environment : J2EE 5.0, MyFaces 1.1.5


also read:

		<h:form id='select'>
			<h:panelGrid columns='1'>
					<h:outputText value='Select a Name : '/>
					<h:selectOneMenu value='#{selectOneBean.name}'>
					<f:selectItem itemValue='SteveJobs' value='SteveJobs'/>
					<f:selectItem itemValue='Sergey Brin' value='Sergey Brin'/>
					<f:selectItem itemValue='Larry Page' value='Larry Page'/>
					<f:selectItem itemValue='Dell' value='Dell'/>
					<f:selectItem itemValue='Mark Anderson' value='Mark Anderson'/>
				<h:commandButton value='Submit' action='#{selectOneBean.submit}'/>


package net.javabeat.myfaces.menu;

public class SelectOneMenuBean {
	private String name;

	public String getName() {
		return name;

	public void setName(String name) {
		this.name = name;

	public String submit() {
		return "selectOneMenu";


		<managed-bean-name> selectOneBean </managed-bean-name>
		<managed-bean-class> net.javabeat.myfaces.menu.SelectOneMenuBean </managed-bean-class>
		<managed-bean-scope> request </managed-bean-scope>
			<from-outcome> selectOneMenu </from-outcome>
			<to-view-id> /pages/menu/selectOneMenuResult.jsp </to-view-id>


			<h:outputText value=&quot;Selected Name is : &quot;/>
			<h:outputText value=&quot;#{selectOneBean.name}&quot;/>

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!