When you build a servlet that incorporates BI Beans thin beans, you should handle HTTP requests in a particular order. When you use BI JSP tags or BI UIX tags, you do not need to worry about this sequence, because the servlet that is created from the tags automatically uses the correct sequence.
When you build a servlet application, you must handle HTTP requests in the following sequence:
Get any state information that the request contains or points to, and set
the state on the thin beans in your application. If you use the ServletRequestHandler
,
then you can call its setState
method to set the state of all
registered thin beans.
Verify the presence of the thin bean before you try to set state, and instantiate any thin beans that are missing. Especially in applications that support bookmarks, the request might reference a bean that has not yet been instantiated.
It is important that you set the state of all the thin beans for which the servlet request has state information, before you handle any events in the request. An event that is handled by one thin bean might affect the state of other thin beans. If, after the bean changes the state of other beans, you set the state of the affected thin bean, then you will overwrite the change that the event caused.
Handle any thin-bean
events that are in the request. If you use the ServletRequestHandler
,
then you can call its handleEvent
method to direct any thin-bean
events to the appropriate thin bean for handling.
Get the state of
any thin bean whose state has changed as a result of the event. It might
be simpler to retrieve the state of all thin beans in your application.
If you use the ServletRequestHandler
, then you can call its
getState
method to retrieve the new state of all of the thin
beans.
Store the state, either in a MutableState
object or in the
URL. You can store State
objects in the HTTP session, to support
the browser's Back functionality. To support
bookmarks, store state in the URL or use
checkpointing and store State
objects in the BI Beans Catalog.
Store the state string, or the state ID, or both, in hidden form fields in the page that you will render, to add information to the URL.
Render the page that will be displayed, including the form that contains the hidden form fields that have either the state ID or the state information.
Managing State in an HTML-Client
Application
Initializing Thin Beans
Setting Thin-Bean State
Handling Thin-Bean Events
Getting Thin-Bean State
Checkpointing Thin-Bean
State
Rendering Thin Beans