A form handler component should be request-scoped or session-scoped. A request-scoped form handler exists for the duration of the request. Consider a form that is held in one page. By clicking the submit button, the user makes a request that, in turn, creates an instance of the form handler. The configured values in the form handler’s properties file are used. You can override the values of these properties using a dsp:setvalue or dsp:input tags. After a user submits the form, the form handler processes the data.

When a form handler spans several pages such as in a multi-page registration process, values entered in each page should persist until final submission. If the form spans only two pages, you can implement the registration process with a request-scoped form handler by designing it to support a redirect: make data from page one available to page two. Only one redirect is available to a given form handler instance , so this approach is valid only for forms that are no longer than two pages.

if a form spans more than two pages, two approaches enable persistence of form values:

Session-scoped form handler

A session-scoped form handler ensures that all form values persist across multiple pages. However, the form remains in memory for the entire user session, so use of multiple form handlers within a single session can incur considerable overhead.

If you use session-scoped form handlers, be sure to reset or clear values between uses of the form handler because values remain in effect throughout the entire session. Also clear error messages so they do not appear in other forms where they are not relevant.

Page-specific request-scoped form handlers

Each page of a multi-page form can use separate, request-scoped form handler instances; all pages share the same session-scoped component. With each form submission, the form handler automatically copies the data to the session-scoped component. That way, if you want page five to hold a list of data entered in pages one through four for validation, you need only reference the relevant properties in the session-scoped component. This technique offers the persistence of a session-scoped form handler and data refresh provided in a request-scoped form handler.

This technique is especially helpful in implementing search form handlers when you want to search results available for future reference. In order to implement this behavior, design your form handler’s submit handler method to retrieve the session-scoped component and set specific properties on it.

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