Form handlers use handleX methods to link form elements with Nucleus components, where X represents the name of a form handler property to set. handleX methods have the following signature:

public boolean handleX (javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response)

A handleX method can also declare that it throws java.io.IOException or javax.servlet.ServletException.

handleX methods are called on form submission. If a corresponding setX method also exists, the setX method is called before the handleX method is called.

Request and Response Object Arguments

The handleX method is passed the request and response objects that encapsulate the request. (See the Java Servlet specifications on how to use these request and response types.) Often, the handler method does nothing with the request and response objects. For example, the handler method might simply redirect the user to another page.

A handleX method can also use the Oracle Commerce Platform extensions to the HttpServletRequest and HttpServletResponse interfaces, DynamoHttpServletRequest and DynamoHttpServletResponse. Thus, your handler method signature can look like this:

public boolean handleX (atg.servlet.DynamoHttpServletRequest request,
                        atg.servlet.DynamoHttpServletResponse response)
Handler Method Returns

The handler method returns a Boolean value, which indicates whether to continue processing the rest of the page after the handler is finished:

Return Value

Action

false

No further values are processed process after the handler is called, and the rest of the page is not served. For example, a handler that redirects the user to another page should return false.

true

Normal processing of the remaining values continues, and the page specified by the form’s action attribute is served.

As mentioned earlier, Oracle Commerce Platform form handlers typically implement the interface DropletFormHandler. This interface has the following methods, which are called at specific points as the form is processed:

Method

When Called:

beforeSet

Before any setX methods are called.

afterSet

After all setX methods are called.

beforeGet

Before any input tags that reference this component are rendered.

afterGet

After page rendering is complete, before the socket is closed.

handleFormException

If an exception occurs when trying to call the setX method of a form.

The beforeGet and afterGet methods are called only when the page is rendered, not when the form is submitted. The beforeSet and afterSet methods are called only when the form is submitted, not when the page is rendered. It is possible to have all four of these methods called on the same page.

See the Quincy Funds demo for an example of form handling. This demo uses form handler to process registration, login, and profile updates.


Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices