The BI Beans thin dialog beans collect information from a user, and then they pass that information to the bean or application code that needs the information. BI Beans thin dialogs include the Export Options dialog, the Find Member dialog, the Print Options dialog, the Printer-Friendly View, the Save As dialog, and the Save Confirmation dialog.
You normally prepare
an object that users click to invoke a thin dialog. When a user clicks the
object, then the object triggers a BIConstants.INIT_EVENT
event.
In a servlet application, you must respond to this event by initializing the
thin dialog. You do not have to provide buttons to invoke the Printer-Friendly
View or the Find Member dialog, but you must initialize these thin dialogs.
In JSP and UIX applications, you do not have to write initialization code. Simply set the required attributes for the tags that you use.
In a servlet application, how you respond to the initialization event depends
on whether you instantiate the thin dialog ahead of time or instantiate it in
response to the initialization event. In either case, the initialization code
must set any information that the thin dialog needs. For example, for the ExportOptions
,
you must set the view to export. The help topic for each thin dialog bean describes
tasks that your initialization code must perform for that thin dialog.
Before you display any thin dialog, you must associate the thin bean with a UIX UINode and put the bean in a form in an HTML page. For most thin dialog beans, you must also set up OK and Cancel buttons or hyperlinks on the same page. You do not need buttons or hyperlinks on dialog pages that contain the Find Member dialog or the Printer-Friendly View.
You must also perform any state-management tasks before you render the dialog page.
Events for initializing thin dialogs occur in the following sequence:
When the user clicks the button or hyperlink that invokes the dialog, an initialization event is placed in the request. For most dialogs, this is BIConstants.INIT_EVENT
. For the Printer-Friendly View, it is BIConstants.INIT_PRINTER_FRIENDLY_VIEW
, and for the Find Member dialog, it is BIConstants.INIT_FIND_MEMBER_EVENT
.
The
ServletRequestHandler
routes the event to the object that is the value of the source
query parameter in the request. This is the thin dialog that is the named target in the event target that has been set on the calling object.
The thin dialog handles the event and sends a Java InitEvent
to all registered listeners.
If the thin dialog is stored in the browser session, then you respond to the InitEvent
in a ThinBeanDialogListener
. You register the listener with the thin dialog bean. The thin dialog calls the handleInitEvent
method of the registered listener. In your implementation of this method, you initialize the dialog and prepare it for display.
The following code is the ThinBeanDialogListener
that has been
registered with an ExportOptions
dialog. This code responds to
the Java InitEvent
that the thin dialog issues to listeners after
it handles the BIConstants.INIT_EVENT
. This code sets the
view name on an ExportOptions
dialog that has been stored in the
browser session. It then specifies the HTML page to be displayed next. That
page contains the ExportOptions
, an OK
button and a Cancel button.
public class exportDialogListener implements ThinBeanDialogListener { public void handleInitEvent(InitEvent e){ QueryParameterProvider provider = e.getQueryParameterProvider(); String viewName = provider.getApplicationQueryParameter("ViewName"); // Get the ExportOptions from the event ExportOption exportOptions = (ExportOptions)e.getSource(); // get the view from the session // first, get the session HTTPSession session = provider.getHttpServletRequest().getSession(false); // get the view ThinDataviewCommon dataView = (ThinDataviewCommon)session.getAttribute(viewName); exportOptions.setView(dataView); // set the Export Options page as the page to display setCurrentApplicationPage(exportOptions); } }
You can instantiate the thin dialog in response to the initialization event. To do so, you check the source
query parameter in each HTTPRequest
for the string that identifies the thin dialog. You should have set this string as the thinBeanTarget
of the EventTarget
of the InitDataEventObject
when you prepared an object to invoke the thin dialog. When the source
query parameter value equals the string that you set in the event target, then you instantiate the thin dialog bean.
If the code that checks query parameters handles more than one event, you should check the event
query parameter for the initialization event. For most thin dialogs, this is the BIConstants.INIT_EVENT
. For the Printer-Friendly View, check for BIConstants.INIT_PRINTER_FRIENDLY_VIEW_EVENT
. For the Find Member dialog, check for BIConstants.INIT_FIND_MEMBER_EVENT
.
The following example checks the source
query parameter for the name of the Export Options dialog. It then checks the event parameter for the BIConstants.INIT_EVENT
. Then it sets up the ExportOptions
for display.
public void handleAppEvent ( HttpServletRequest request, HttpServletResponse response ) throws Exception { String event = null, source = null; QueryParameterProvider provider = new ServletQueryParameterProvider(request, response);; source = provider.getQueryParameter ( BIConstants.SOURCE ); // check source for "exportOptions" if ( source.equals ( "exportOptions")){ event = provider.getQueryParameter( BIConstants.EVENT ); if ( event.equals ( BIConstants.INIT_EVENT ) ){ String viewName = provider.getApplicationQueryParameter("ViewName"); // get the view from the session // first, get the session HTTPSession session = provider.getHttpServletRequest().getSession(false); // get the view ThinDataviewCommon dataView = (ThinDataviewCommon)session.getAttribute(viewName); // instantiate the ExportOptions and set the view if ( dataView != null ) { exportOptions = new ExportOptions ( ); exportOptions.setView ( dataView ); exportOptions.setThinBeanName ("myExportOptions" ); eventParams = new Hashtable ( ); eventParams.put ( Constants.TARGET_PAGE_PARAM, SampleConstants.Page.ANALYZE ); eventTarget = new EventTargetImpl ( null, null, dataView.getThinBeanName ( ), eventParams ); exportOptions.setEventTarget ( BIConstants.EXPORT_EVENT, eventTarget ); } //end if dataView // set the Export Options page as the page to display setCurrentApplicationPage(exportOptions); } //end if event } // end if source //