- usage of h:selectOneMenu
<h:selectOneMenu value="#{manageStudent.student.gender}">
<f:selectItem itemLabel="- Select Gender -" itemValue=""/>
<f:selectItems value="#{manageStudent.genders}"/>
</h:selectOneMenu>
- get HttpServletRequest and HttpServletResponse in managed bean
HttpServletRequest request =
(HttpServletRequest)FacesContext
.getCurrentInstance()
.getExternalContext()
.getRequest();
HttpServletResponse response =
(HttpServletRequest)FacesContext
.getCurrentInstance()
.getExternalContext()
.getResponse();
- include another xhtml page
main.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
<ui:include src="content.xhtml"/>
</h:body>
</html>
content.xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h2>Hello</h2>
</ui:composition>
- create template for xhtml
template.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title><ui:insert name="title">Title here</ui:insert></title>
</h:head>
<h:body>
<ui:insert name="content">Content here</ui:insert>
</h:body>
</html>
welcome.xhtml
<ui:composition template="template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:define name="title">
Welcome!!
</ui:define>
<ui:define name="content">
<p>Hello World!!!</p>
</ui:define>
</ui:composition>