Routing Thin-Bean Events

Your servlet application is responsible for routing thin-bean events to the appropriate BI Beans thin bean for handling. The source query parameter in the request identifies the source of the event, to help you route the event. The source is the name of the thin bean to which the event should be routed.

BI Beans provides a ServletRequestHandler that handles routing for you. The ServletRequestHandler sends each event to the appropriate thin bean.

To use the ServletRequestHandler, you register each instance of the ThinBeanUI instance that you create with the ServletRequestHandler. Then, for each HttpServletRequest, you create a QueryParameterProvider, which you then pass to the handleEvent method of the ServletRequestHandler.

The following code shows how to register a thin bean with the ServletRequestHandler.


// construct the ServletRequestHandler ServletRequestHandler requestHandler = new ServletRequestHandler(); // construct a thin bean ThinCrosstab crosstab = new ThinCrosstab(); // register the crosstab with the ServletRequestHandler requestHandler.registerThinBean(crosstab);

The following code shows how to pass the servlet request to the ServletRequestHandler. This example includes methods for managing the state of the registered beans.


// construct a QueryParameterProvider, // passing the request and the response from the HttpServletRequest QueryParameterProvider provider = new ServletQueryParameterProvider (request, response); // requestHandler is my ServletRequestHandler // set the state of all the registered beans requestHandler.setState(provider); // route the event int handled = requestHandler.handleEvent(provider); // get the new state of all registered beans Dictionary state = requestHandler.getState(provider.getURLEncoder()); // put the state in hidden form fields // code not provided in this example // render HTML -- code not provided in this example }

To change the routing of an event, you set an event target for the event.