Developing Web 2.0 applications
with JavaServerFaces
and Dreamweaver
>> Just Became Easier
Documentation
Search
  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
  12. JSF Tag Reference
JSF Core Tag Library
  f:actionListener
  f:ajax
  f:attribute
  f:convertDateTime
  f:convertNumber
  f:converter
  f:event
  f:facet
  f:loadBundle
  f:metadata
  f:param
  f:phaseListener
  f:selectItem
  f:selectItems
  f:setPropertyActionListener
Selected f:subview
  f:validateBean
  f:validateDoubleRange
  f:validateLength
  f:validateLongRange
  f:validateRegex
  f:validateRequired
  f:validator
  f:valueChangeListener
  f:verbatim
  f:view
  f:viewParam
If you like this documentation, please take a look at my book:

12. JSF Core Tag Reference

Documentation > JSF > JSF Tag Reference > JSF Core Tag Library > f:subview

f:subview

The Subview tag creates a naming container (a container component with a unique identifier) that contains all JavaServer Faces core and custom tags on a nested page via "jsp:include" or any tag that dynamically includes another page from the same web application, such as JSTL's "c:import".

The subview tag wraps JSF components contained in an included JSP or Facelets page that allows nested views. One advantage of this tag is that include files can be reused. Since JSF requires a unique ID for each component, the subview tag creates a unique "namespace" for child components.

JSF Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">
<body>
<f:view>
	<h:form id="form_1">
		<h:outputLabel value="Home Address" id="outputLabel_1" style="font-weight:bold" />
		<f:subview id="subview_1">
			<ui:include src="/WEB-INF/includes/addressPanel.xhtml">
				<ui:param name="address" value="#{customerController.customer.homeAddress}" />
			</ui:include>
		</f:subview>
		<h:outputLabel value="Work Address" id="outputLabel_2" style="font-weight:bold" />
		<f:subview id="subview_2">
			<ui:include src="/WEB-INF/includes/addressPanel.xhtml">
				<ui:param name="address" value="#{customerController.customer.workAddress}" />
			</ui:include>
		</f:subview>
	</h:form>
</f:view>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

/WEB-INF/includes/addressPanel.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core">
<h:head id="head_1"/>
<body>
<ui:composition>	
	<h:panelGrid columns="2" id="panelGrid_1">
		<h:outputLabel value="Street address: " id="outputLabel_1" />
		<h:inputText value="#{address.streetAddress}" id="inputText_1" />
		<h:outputLabel value="City: " id="outputLabel_2" />
		<h:inputText value="#{address.cityName}" id="inputText_2" />
		<h:outputLabel value="Country" for="selectOneMenu_1" id="outputLabel_3" />
		<h:selectOneMenu value="#{address.country}" converter="countryConverter" 
		                 id="selectOneMenu_1">
			<f:selectItems value="#{countryController.countries}" var="country" 
			               itemLabel="#{country.name}" itemValue="#{country}" />
		</h:selectOneMenu>
	</h:panelGrid>
</ui:composition>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

Rendered Output

Rendered f:subview tag

HTML Output

...

<tr>
  <td>
     <label id="form_1:subview_1:outputLabel_1">
	Street address:
     </label>
  </td>
  <td>
     <input id="form_1:subview_1:inputText_1" type="text" 
	    name="form_1:subview_1:inputText_1" />
  </td>
</tr>

...

<tr>
  <td>
      <label id="form_1:subview_2:outputLabel_1">
	Street address:
      </label>
  </td>
  <td>
      <input id="form_1:subview_2:inputText_1" type="text" 
	     name="form_1:subview_2:inputText_1" />   
  </td>
</tr>

Tag Attributes

binding Expression
 
The value-binding expression linking this component tag to a backing bean property.
id Text
Required
The unique identifier value for this component. The value must be unique within the closest naming container.
rendered Boolean
 
A value-binding expression that evaluates to a Boolean condition indicating if this component should be rendered.