Java web development using hibernate, jsp and servlets, 2007

Page 202

Web Development with Java

190

Table 6.4 Correlation between the form elements and the bean properties. Element

Property

Name

Type

Accessor

Type

secretCode happiness extra comments grade team

password radio checkbox textarea select select

getSecretCode getHappiness getExtra getComments getGrade getTeam

single-valued single-valued multiple-valued single-valued single-valued multiple-valued

6.5.4 Java Bean: Complex Elements The edit page is the most important file in the application; it defines the data. Once the edit page has been created, it is a straightforward process to create the bean. The names of the bean properties will correspond to the names of the form elements in the edit page. The type of form element that is used in the edit page will determine whether the bean uses a single-valued property or a multiplevalued property. The names and types of the form elements from the edit page are listed in Table 6.4 along with the corresponding name of the accessor for the property and the type of the property. All of the single-valued properties will look like the property for the text area field, comments, from Listing 6.1. All of the multiple-valued properties will look like the property for the checkbox group, extra, from Listing 6.2. The only differences for the other elements will be the name of the property and, possibly, the type of the property.

6.5.5 Confirm.jsp, Process.jsp: Complex Elements The data from the bean is displayed in the confirm page. A nested ordered list is used to display the data from the bean. A loop is used to display the data from the multiple-valued elements: extra and team (Listing 6.4). ... <%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”core” %> <html> <head> <meta http-equiv=”content-type” content=”text/html;charset=utf-8”> <title>Complex Form - Confirm Page</title> </head> <body> <p> This page displays the values from some complex form elements. </p>


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.