JAVA SERVER FACES (JSF)

JSF PROJECTS

JSF PROJECT 1

JSF Examples

JSF EXAMPLE

adplus-dvertising
Subview Application
Previous Home Next

Tag description: JSF <f:subview> Tag is work as similar as "jsp:include" , means both provide a custom action that dynamically includes another page from the same web application.

Code

<f:subview>

Example:

Step 1: Welcome page of Example

 Name= welcomeJSF.jsp
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%--
This file is an entry point for JavaServer Faces application.
--%>
<f:view>
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
   <title>r4r.co.in</title>
  </head>
  <body>
   <h1><h:outputText value="Tag <f:subview> Example"/></h1>
   <h:form >
<%-- Header page include through subview  --%>
<f:subview id="header" >
  <jsp:include page="headerJSF.jsp" flush="true" />
</f:subview>
<%-- Footer page include through subview --%>
<f:subview id="footer" >
  <jsp:include page="footerJSF.jsp" flush="true" />
</f:subview>
   </h:form>
  </body>
</html>
</f:view>

Step 2: Header page of example

<%--
Name= headerJSF
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:view>
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>r4r.co.in</title>
  </head>
  <body>
   <h1>Header Page!</h1>
   <h:outputLabel value="Header Page include through <f:subview> tag" />
  </body>
</html>
</f:view>

Step 3: Footer page of example

<%--
   Name= footerJSF.jsp 
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:view>
<html>
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>r4r.co.in</title>
  </head>
  <body>
   <h1>Footer Page!</h1>  
   <h:outputLabel value="Footer Page include through <f:subview> tag" />
  </body>
</html>
</f:view>
Output:
Previous Home Next