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;/>



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

  • sucheta

    hi in above examople when i try to access name value i am getting null pointer exception