SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 521 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"

0" encoding="ISO-8859-1" ?>
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">


path="/WEB-INF/results/confirm-registration.jsp"/>


type="coreservlets.RegisterAction1">

type="coreservlets.RegisterAction2">
10.5 Handling Request Parameters with Form Beans 481
10.5 Handling Request Parameters
with Form Beans
In the previous example, we explicitly called request.getParameter to obtain
the form data. We used this manual approach because we wanted to concentrate only
on the action mappings, forward entries, and structure of the Action class. In a
real application, however, making repeated request.getParameter calls is
tedious and error prone. Fortunately, Struts has a very convenient and powerful facility
that simplifies this process: form beans.
Basically, a form bean is little more than a JavaBean with property names that correspond
to request parameter names. When a user submits a request, the system
instantiates the bean; populates it based on the incoming request parameters (i.e., if
any incoming parameter name matches a bean property name, it calls the corresponding
setter method); stores it in request, session, or application scope;
and passes it to the execute method of your Action.


Pages:
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533