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:
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.
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.
ThinCrosstab crosstab = new ThinCrosstab ( );
crosstab.setThinBeanName ( DATAVIEW_NAME );
crosstab.setPagingControlVisible ( true );
crosstab.setDataSource ( dataSource );
handler.registerThinBean ( crosstab );
After we have a view, the toolbar is initialized and hooked up with the view. The following code initializes the toolbar.
ViewToolbar viewToolbar = new ViewToolbar ( );
viewToolbar.setThinBeanName ( TOOLBAR_NAME );
viewToolbar.setView ( crosstab );
viewToolbar.addViewToolListener ( new ViewToolAdapter ( biHttpSession
) );
handler.registerThinBean ( viewToolbar );
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.
ServletRequestHandler handler = biHttpSession.getServletRequestHandler
( );
ServletQueryParameterProvider provider = new ServletQueryParameterProvider
( request, response );
handler.handleEvent ( provider );
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 ( );
FormBean
UIX component.
FormBean rootNode = new FormBean ( FORM_NAME );
ViewToolbar viewToolbar = ( ViewToolbar ) handler.getThinBean ( TOOLBAR_NAME
);
if ( viewToolbar != null ) {
ViewToolbarBean viewToolbarBean = new ViewToolbarBean ( viewToolbar
);
rootNode.addIndexedChild ( viewToolbarBean );
}
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.
To run the BIToolbarServlet example within JDeveloper, simply right-click on BIToolbarServlet.java under using_toolbar.jpr, and click 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.
![]() |
|
---|---|
Copyright © 2002, 2003 Oracle. All Rights Reserved. |
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. |