The BIToolbarServlet demonstrates how the toolbar interacts with a view in a
servlet application. The class inherits user login functionality
from BIServlet. The sample displays a view and a toolbar. The toolbar
displays the following tools:
View
Layout
Sort
Favorites
Setup Requirements
If you have not already done so, you must perform several installation
and configuration tasks, then open the workspace servlet\Servlet.jws
under the samples directory within JDeveloper. All the necessary
files for this sample can be found in the using_toolbar.jpr project
under the Servlet.jws workspace.
Code Highlights
The following section provides a walkthrough and explanations of the code fragments:
The processRequest method is called by the base class after a successful user login.
The first step of the application is to initialize the thin beans. The following code
initializes a crosstab thin bean.
The application adds a ViewToolListener listener with the ViewToolbar thin bean.
The thin bean fires an event when an event occurs on the client. The application
can change the displayed view type when the event occurs.
During changing the view type, the common attributes of the old view can be transferred
from the source view to the new target view. This can be done by setting the XML of the
old view to the new view.
The application delegates to the ServletRequestHandler for handling thin bean events.
The application can render the HTML using a combination of raw HTML and thin beans.
For rendering HTML, the application can retrieve the PrintWriter from the HttpResponse
object and use println statements to output HTML to the client.
response.setContentType ( "text/html" );
PrintWriter out = response.getWriter ( );
The thin beans are added to a FormBean UIX component.
The thin beans in a FormBean UIX component are rendered as follows:
ServletRenderingContext renderingContext = new ServletRenderingContext(
this, request, response, out );
renderingContext.setConfiguration ( BI_CONFIGURATION_KEY );
rootNode.render ( renderingContext );
If the URL contains a thin bean event, the event and the target bean of the
event are displayed on the page.
While cleaning up the BIHttpSession related to a client, the resources allocated
by the Servlet need to be cleaned up. This includes beans allocated by the servlet
for the session. The close method (implemented by QueryClient)
should be called to release data source-related resources. The cleanUp
method should be called on the ThinGraph to release Graph related
resources.
How To Run
To run the BIToolbarServlet example within JDeveloper, simply right-click
BIToolbarServlet.java under using_toolbar.jpr, then
choose Run BIToolbarServlet.java. When the application
appears in a browser, enter the username and password of the user that owns
the BI Beans Catalog (e.g., BIBCAT). You can use the different functions on
the toolbar to manipulate the view.