background image

Screen Definitions

<< Tag Handlers | Parameters for the URL >>
<< Tag Handlers | Parameters for the URL >>

Screen Definitions

public int doTag() {
try {
screens = new HashMap();
getJspBody().invoke(null);
Definition definition = new Definition();
PageContext context = (PageContext)getJspContext();
ArrayList params = (ArrayList) screens.get(screenId);
Iterator ir = null;
if (params != null) {
ir = params.iterator();
while (ir.hasNext())
definition.setParam((Parameter)ir.next());
// put the definition in the page context
context.setAttribute(definitionName, definition,
context.APPLICATION_SCOPE);
}
}
The table of screen definitions is filled in by ScreenTag and ParameterTag from text provided
as attributes to these tags.
Table 8­14
shows the contents of the screen definitions hash table for
the Duke's Bookstore application.
TABLE 8­14
Screen Definitions
Screen ID
Title
Banner
Body
/bookstore
Duke
's Bookstore
/banner.jsp
/bookstore.jsp
/bookcatalog
Book Catalog
/banner.jsp
/bookcatalog.jsp
/bookdetails
Book Description
/banner.jsp
/bookdetails.jsp
/bookshowcart
Shopping Cart
/banner.jsp
/bookshowcart.jsp
/bookcashier
Cashier
/banner.jsp
/bookcashier.jsp
/bookreceipt
Receipt
/banner.jsp
/bookreceipt.jsp
If the URL passed in the request is /bookstore, the Definition object contains the items from
the first row of
Table 8­14
(see
Table 8­15
).
TABLE 8­15
Definition Object Contents for URL /bookstore
Title
Banner
Body
Duke
's Bookstore
/banner.jsp
/bookstore.jsp
The parameters for the URL /bookstore are shown in
Table 8­16
. The parameters specify that
the value of the title parameter, Duke's Bookstore, should be inserted directly into the output
stream, but the values of banner and body should be included dynamically.
Programming Simple Tag Handlers
Chapter 8 · Custom Tags in JSP Pages
271