themselves. In any case, you need to develop the layout (or layouts) well ahead of any actual development. The default layout for the Storefront application was presented in Example 14-2. This layout will be used as an example throughout this chapter. 14.3.4 Passing Parameters to the Layout The layout tile shown in Example 14-2 is generic. It doesn’t know anything about the itemdetail.jsp content or any of the other pages, for that matter. This is intentional, as it allows us to reuse this layout for many pages. Instead of being hardcoded within the layout page, the content is supplied or “passed” as parameters to the layout page at runtime. Let’s look at the signin.jsp tile for the Storefront application, shown in Example 14-5. Example 14-5. The signin.jsp tile for the Storefront application <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %> The purpose of the put tags in Example 14-5 is to supply the layout tile, which is specified in the enclosing insert tag, with content. The values of the name attributes in Example 14-5 (as in the other tiles shown in Examples Example 14-3 and Example 14-4) must match the ones that the layout tile is expecting. The insert tag optionally can include an attribute that will cause the tag to not write out anything when it can’t find a value for an expected attribute. By default, a runtime exception is thrown when an attribute has not been supplied. 14.4 The Tiles Tag Library This section introduces the JSP custom tags used by the Tiles framework. Table 14-1 lists the tags available to the framework. The tags are very similar to the ones provided in any template-based framework, but Tiles contains more functionality. Table 14-1. Tags within the Tiles tag library Tag name Description add Add an element to the surrounding list. definition Create a tile component definition.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.
This entry was posted
on Saturday, October 27th, 2007 at 9:19 pm and is filed under Domain.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.