Java Reference
In-Depth Information
Entering the tag file name into the first field will result in the value of the Created
File field to be filled automatically, default values for all other fields are sensible and
in most cases there is no need to modify them.
At this point, NetBeans creates an initial tag file that we can use as a starting point.
<%@tag description="put the tag description here"
pageEncoding="UTF-8"%>
<%-- The list of normal or fragment attributes can be specified here:
--%>
<%@attribute name="message"%>
<%-- any content can be specified here e.g.: --%>
<h2>${message}</h2>
Tag files can contain one or more tag directives. The tag directive is similar to
the page directive in a JSP. The generated tag directive contains two attributes, a
description attribute used to describe the purpose of the tag, and a pageEncoding
attribute used to set the page encoding of the tag.
The attribute directive allows us to specify what attributes may be sent from the
JSP using our tag.
Using the above markup as a starting point, we will now create a tag file that will
generate an HTML table containing a series of input fields for entering an address:
<%@tag description="Address Input Field" pageEncoding="UTF-8"%>
<jsp:useBean id="addressBean" scope="session"
class="com.ensode.netbeansbook.AddressBean"/>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/c<%-- The list
of normal or fragment attributes can be specified here: --%>
<%@attribute name="addressType" required="true" %>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>Line 1:&nbsp;</td>
<td>
<input type="text" size="20"
name="${addressType}_line1"
id="${addressType}_line1"
value="${addressBean.line1}"/>
</td>
</tr>
<tr>
<td>Line 2:&nbsp;</td>
<td>
 
Search WWH ::




Custom Search