public interface ViewerContext
You can set the ViewerContext to be used by the viewer in SwingReportViewer.setViewerContext(ViewerContext)
.
For example, if you'd like to implement your own behavior in the case of an error, or would like to
catch certain errors, simply write your own ViewerContext and set the Viewer to use your
ViewerContext instead of the default one. The easiest way would simply be to extend
from SwingViewerContext, the default implementation of ViewerContext and to implement
only the methods you are interested in. For example:
SwingReportViewer viewer = new SwingReportViewer();
viewer.setViewerContext(new SwingViewerContext() {
public void showError(Throwable e, Object source) {
// Your error handling comes here...
}
});
Note that most often the source given for an error will be a ReportView, allowing you to make further adjustments
to your settings for that view.
For example, if an UnknownHostException comes for a ReportView,
you might want to make an adjustment to the ReportView's RenderData object, making it fall back
onto a backup report server instead of the original one:
class MyErrorHandler extends SwingViewerContext {
public void showError( Throwable e, Object source ) {
if (source instanceof ReportView && e.getCause() instanceof UnknownHostException) {
((ReportView)source).getReportData().setReportLocation( "http://www.backupserver.com:9000/?report=file:backupreport.rpt" );
((ReportView)source).reload();
}
}
}
ReportViewer.setViewerContext(ViewerContext)
Modifier and Type | Method and Description |
---|---|
ExportProgress |
export(ReportView view)
This method is called when the export action is to be performed.
|
Progress |
print(ReportView view)
This method is called when the print action is to be performed.
|
void |
showError(java.lang.Throwable e,
java.lang.Object source)
This method will be called whenever an error occurs and thereby allows the implementor of this interface to handle the error
as seen fit.
|
void |
showHelp(java.lang.String helpPageKey,
java.awt.Component comp)
Opens a HelpPage with a key in a window that corresponds to the component.
|
void |
showInfo()
Shows the info screen of this viewer.
|
boolean |
showPrompts(PromptData[] prompts,
RenderData renderData)
Handles a prompt request from the server.
|
void |
showStatusMessage(ReportView view,
java.lang.String message,
boolean isError)
Handled when a status message is to be displayed.
|
void |
showUrl(java.lang.String url,
java.util.Properties props)
Handles opening a URL, e.g. a click on a hyperlink.
|
void showInfo()
void showError(java.lang.Throwable e, java.lang.Object source)
e
- The Throwable of the error that actually occurred.source
- The source where the exception occurred, such as the SwingReportView or SwingPageView.void showStatusMessage(ReportView view, java.lang.String message, boolean isError)
view
- the ReportView which is to display the status message, must not be nullmessage
- the message to be displayedisError
- true if the message is an error message, false otherwise.Progress print(ReportView view)
view
- ReportView whose report is to be printed.ExportProgress export(ReportView view)
view
- ReportView whose report is to be exportedvoid showUrl(java.lang.String url, java.util.Properties props) throws java.net.MalformedURLException
url
- String of the hyperlink URL which is to be shown. The length need to be > 0.props
- Extra optional Properties for the URL connection (can be null for no extra properties)java.net.MalformedURLException
- The supplied URL String is invalid.boolean showPrompts(PromptData[] prompts, RenderData renderData)
PromptData.setChosenValues(Object)
.prompts
- list of required promptsrenderData
- RenderData of the report requiring promptsvoid showHelp(java.lang.String helpPageKey, java.awt.Component comp)
helpPageKey
- key of the page to opencomp
- component to use when opening the windowCopyright © 1999-2020 by i-net software GmbH