The BIAdvancedToolbarServlet
demonstrates how the enable advanced
hyperlinks in the toolbar servlet application. The class inherits PPR and toolbar
functionality from BIPPRToolbarServlet
. This sample displays advanced
links for the Format tool and the Stoplight tool so that the user can access
the advanced pages of the FormatCustomizer by clicking the hyperlinks.
The following section provides a walkthrough and explanations of the code fragments:
After the view and the toolbar are initialized, the following code initializes a FormatCustomizer thin bean.
FormatCustomizer formatCustomizer = new FormatCustomizer();
formatCustomizer.setThinBeanName(FORMAT_CUSTOMIZER_NAME);
formatCustomizer.setGridView((ThinGridView)presentation.getView());
formatCustomizer.setPartialRenderEnabled(true);
handler.registerThinBean(formatCustomizer);
The application adds a DialogListener
listener with the FormatCustomizer
thin bean. The thin bean fires events when the user chooses Apply
or Cancel to exit the FormatCustomizer. The application
should display the presentation page so the user can view the result of interaction
with the FormatCustomizer.
formatCustomizer.addDialogListener(new DialogAdapter(biHttpSession));
The application adds a ViewToolListener
with the ViewToolbar
thin bean. The thin bean fires a ViewToolEvent
when the user clicks
an advanced link in the Format tool or the Stoplight tool. The application should
display the FormatCustomizer page in response to this event. The application
continues to display the FormatCustomizer until the user exits the FormatCustomizer.
viewToolbar.addViewToolListener(new ViewToolAdapter(biHttpSession));
The followin code enables advanced links for the Format tool and the Stoplight tool:
for (int i = 0; i < viewToolbar.getChildCount(); i++) {
Object child = viewToolbar.getChild(i);
if (child instanceof FormatTool || child instanceof
StoplightTool)
((BaseViewTool)child).setAdvancedLinksDisplayed(true);
}
There is special handling for the FormatCustomizer bean. If the application
event indicates that the FormatCustomizer should be displayed, a PageLayoutBean
,
which contains a UIX component for the FormatCustomizer thin bean, is added
to the form instead of a presentation bean.
PageLayoutBean pageLayout = new PageLayoutBean();
PageLayoutUtils.initPageLayoutBean(pageLayout, formatCustomizer);
FormatCustomizerBean formatBean = new FormatCustomizerBean(formatCustomizer);
pageLayout.addIndexedChild(formatBean);
PageButtonBarBean pageButtons = new PageButtonBarBean();
String[] events = formatCustomizer.getPageButtonEvents();
if (events != null) {
for (int i = 0; i < events.length; i++) {
ButtonBean button = new ButtonBean();
NodeUtils.setTextAndAccessKey(button,
formatCustomizer.getPageButtonEventLabel(events[i]));
button.setOnClick(formatCustomizer.getPageButtonEventOnClick(events[i]));
pageButtons.addIndexedChild(button);
}
}
pageLayout.setContentFooter(pageButtons);
rootNode.addIndexedChild(pageLayout);
FormBean
UIX component are rendered as in BIPPRToolbarServlet
.
If the url contains a thin bean event, the event and the target bean of the event are displayed on the page.
While the code cleans up the BIHttpSession
that is related to
a client, the resources allocated by the servlet need to be cleaned up. This
includes beans that the servlet allocates for the session. The close
method (implemented by QueryClient
) should be called to release
resources that are related to the data source. The cleanUp
method
should be called on the ThinGraph
to release Graph-related resources.
Copyright © 2004 Oracle Corporation.
All Rights Reserved. |