This BIViewServlet demonstrates how Thin BI Beans can be used in a servlet application. The class inherits user login functionality from BIServlet. The sample displays linked graph and crosstab. The FindMember tool is utilized by the sample to enable virtualized paging control.
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 linking_presentations.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.
DataSource data = getDefaultDataSource(request);
ThinCrosstab crosstab = new ThinCrosstab();
crosstab.setThinBeanName(CROSSTAB_NAME);
crosstab.setPagingControlVisible(true);
crosstab.setDataSource(data);
handler.registerThinBean(crosstab)
ThinGraph graph = new ThinGraph();
graph.setThinBeanName(GRAPH_NAME);
graph.setDataSource(data);
Because both graph and crosstab are given the same instance of the data source, they will behave as linked views.
The application delegates to the ServletRequestHandler for handling thin bean events like drilling, paging etc.
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 ( );
The thin beans are added to a FormBean UIX Component.
FormBean rootNode = new FormBean ( FORM_NAME );
CrosstabBean crosstabNode = new CrosstabBean();
rootNode.addIndexedChild(crosstabNode);
GraphBean graphNode = new GraphBean();
rootNode.addIndexedChild(graphNode); ThinCrosstab crosstab = (ThinCrosstab)handler.getThinBean(CROSSTAB_NAME);
ThinGraph graph = (ThinGraph)handler.getThinBean(GRAPH_NAME); crosstabNode.setCrosstab(crosstab);
graphNode.setGraph(graph);
There is special handling for the FindMember thin bean. If the application event indicates that the FindMember thin bean should be displayed, a UIX component for the FindMember thin bean is added to the form instead of a crosstab and table.
FindMemberBean findNode = new FindMemberBean();
rootNode.addIndexedChild(findNode);
FindMember find = (FindMember)handler.getThinBean(FINDMEMBER_NAME);
findNode.setFindMember(find);
The thin beans in the FormBean UIX component are rendered as follows:
ServletRenderingContext renderingContext = new ServletRenderingContext(
this, request, response, out );
renderingContext.setConfiguration ( BI_CONFIGURATION_KEY );
rootNode.render ( renderingContext );
While cleaning up the BIHttpSession related to a client, the resources allocated by the Servlet need to be cleaned up. This includes thin beans allocated by the servlet for the session. The close method (implemented by QueryClient) should be called to release datasource related resources.
To run the BIViewServlet example within JDeveloper, simply right-click on BIViewServlet.java under linking_presentations.jpr, and choose Run BIViewServlet.java. When the application appears in a browser, enter the username and password of the user that owns the BI Beans Catalog (e.g. BIBEANS). When you manipulate the graph, the crosstab changes accordingly and vice versa.
![]() |
|
---|---|
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. |