Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 5
<f:subview>core tag. This tag can either be in the included page or around the include statement.
So, let's say we had the following snippet in a JSP page:
<f:view> ... <jsp:include page="foo.jsp"/> ... </f:view>
Foo.jsp might look like this:
<f:subview> <h:outputText value="heyah!"/> ... <f:verbatim> <b>Template text.</b> <customtag:dothis/> </f:verbatim> </f:subview>
As you can see, the entire included page is enclosed in an
<f:subview> tag, and all non-JSF tags and template text are enclosed in an
<f:verbatim> tag. Alternatively, we could move the
<f:subview> tag into the first page, around the
Using a static include is much simpler. There are no restrictions—you don't even have to use the
In the last example, we showed a fictitious custom tag,
<customtag:dothis>, that performs some random task. This underscores an important point: you can use JSF with other JSP custom tags.
All of this talk about JSF's custom tag libraries is nice, but what if you have your own custom tags, or third-party ones? Or what if you're using the JSP Standard Tag Library (JSTL), which is a set of standard tags that do all of those neat things we just mentioned? For the most part, you can mix and match them with JSF tags. Faces tags can be nested within other tags and vice versa. Some products, like IBM's WebSphere Application Developer, encourage this approach, while others, like Sun's Java Creator Studio, opt for a pure JSF approach. Oracle's JDeveloper on the other hand, lets you mix and match, but also encourages the pure JSF approach.
Note: Whenever you nest a JSF tag inside a non-JSF custom tag, you must assign the JSF tag a component identifier.
Because JSTL is standard and familiar to many, we'll use it to demonstrate the use of JSF with custom tags. (If you're thirsty for general information on JSTL, check out Shawn Bayern's excellent book, JSTL in Action.) Let's start with the simple example (shown in Listing 1) that mixes and matches some JSTL tags with JSF tags. This code imports both JSF tag libraries and the core JSTL tag libraries.
Listing 1. Mixing JSTL tags with JSF tags
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <html> <head> <title>JSF in Action: JSTL Example 1 - Mixing JSF with other custom tags </title> </head> <body bgcolor="#FFFFFF"> <f:view> <h1> <h:outputText value="Example of using JSF tags with other custom tags"/> </h1> <p> <b> <c:out value="Here's the value of your web.xml (don't do this at home):"/> </b> <blockquote> <f:verbatim> <c:import url="WEB-INF/web.xml"/> </f:verbatim> </blockquote> </p> </f:view> </body> </html></code>
In this example, both JSTL and JSF tags are nested within the JSF <f:view> tag, which defines the start of the JSF component tree. The example uses the JSF
HtmlOutputText component (
<h:outputText>) and the JSTL
<c:out> tag to display text. A JSTL
<c:import> tag includes the system's
web.xml file in the page (this isn't exactly something you want to share with others, so don't do this on a real server). Because
web.xml is an XML file, the
<c:import> tag is nested in an
<f:verbatim> tag, which is a JSF
UIOutput component whose renderer escapes the XML so it can be displayed normally in an HTML page. This example doesn't do much, but
it does demonstrate the ability to use different tags on the same page together.
|Forum migration complete By Athen|
|Forum migration update By Athen|
|Getting around JSF: The role of JSP By JavaWorld|