Java Reference
In-Depth Information
Listing 14.11
Action mapping for /viewCategory
name="catalogBean" scope="session" validate="false">
<forward name="success" path="/catalog/Category.jsp"/>
For the final touch, let's configure the action mapping, as shown in listing 14.11.
The mapping requires us to specify a path—in this case, /viewCategory . We then
use the type attribute to identify the fully qualified class name of the Action class
that will be used to process the request. In this example, our type is BeanAction .
BeanAction will relay the request to a behavior method located on the form bean
that the action mapping uses. This is determined based on the form bean name
used in the name attribute of the action mapping. Here we will use the catalog-
Bean that we configured earlier. We then use the scope attribute to specify that the
form remain in a session scope. We set the validate attribute to false because
there is no input to validate.
Lastly, the <forward> tag, which rests in the body of the action mapping, is
used to determine which page will be forwarded to. The name attribute maps to
the value returned by the behavior method of the presentation bean. In our case,
we will always receive a return value of success and thus forward to /catalog/
Category.jsp .
Next let's try our hand at the service layer.
14.7 Writing your service
The service layer will consist of just two pieces: the service interface and the imple-
mentation. The service class is meant to be a coarse-grained class that pulls
together more fine-grained data access calls. This may sound quite simple, but the
contents of a service class can pose some difficulties. Since it is important to keep
our service classes clean of any database-specific information, we need to take
extra measures to ensure proper abstraction.
Search WWH ::

Custom Search