Startseite / Plugin-Entwicklung / Universelle Erweiterungen / Reports (veraltet) / Codebeispiel / Report-Aktionen

<< Kapitel „Transfer-Handler“

Report Items

Access API documentation:

Report items enable interaction with individual report entries by executing functionality on-click. Items are displayed as buttons associated with a report entry, while a single, default item may be executed by clicking on the report entry itself.

Two kinds of report items may be implemented:

Executable Report Item

An executable report item class implements one or both of the following interfaces to indicate compatibility with a FirstSpirit client:

Report items returned by a report plug-in's getItems or getDefaultItem method will be silently ignored by a client if the report item does not implement the matching interface. I.e., if a report plug-in is loaded in SiteArchitect and provides a report item object that is an implementation of only WebeditExecutableReportItem, the SiteArchitect will not load this report item.

Both interfaces share identical method definitions with the exception of those methods that provide icons for display in the user interface.

public class ExampleExecutableReportItem
implements JavaClientExecutableReportItem<ExampleReportObject>, WebeditExecutableReportItem<ExampleReportObject> {

public boolean isVisible(final ReportContext<ExampleReportObject> context) {
final ExampleReportObject reportEntryObject = context.getObject();
return !reportEntryObject.toString().isEmpty();
}

public boolean isEnabled(final ReportContext<ExampleReportObject> context) {
return true;
}

public String getLabel(final ReportContext<ExampleReportObject> context) {
return "Example Executable Report Item";
}

public Icon getIcon(final ReportContext<ExampleReportObject> context) {
return new ImageIcon(this.getClass().getResource("example_executable_reportitem.png");
}

public String getIconPath(final ReportContext<ExampleReportObject> context) {
return "example_report/example_executable_reportitem.png";
}

public void execute(final ReportContext<ExampleReportObject> context) {
final ExampleReportObject reportEntryObject = context.getObject();
final OperationAgent operationAgent = context.requestSpecialist(OperationAgent.TYPE);
if (operationAgent != null) {
final RequestOperation requestOperation = operationAgent.getOperation(RequestOperation.TYPE);
if (requestOperation != null) {
requestOperation.perform("Executable report item activated on report entry" +
reportEntryObject.toString()
);
}
}
}

}

isVisible()

This method determines if the report item's button representation should be visible in the user interface.

Important The return value of this method only has effect upon report items shown as buttons attached to report list entries. A report plug-in's default report item is always assumed to be visible.

isEnabled()

This method determines if the report item should be enabled.

getLabel()

This method provides the text displayed in the report item's tool tip.

getIcon()

This method provides the icon displayed in this report item's button representation.

Important This method is only available in the interface JavaClientExecutableReportPlugin. The return value of this method affects only report items shown in the SiteArchitect.

getIconPath()

This method provides the URL of an icon that should be displayed in this report item's button representation.

Important This method is only available in the interface WebeditExecutableReportPlugin. The return value of this method affects only report items shown in the ContentCreator.

execute()

The code in this method will be executed when the report item's button or snippet (for a default report item) is activated by user interaction.

JavaScript-Providing Report Item (ContentCreator only)

Important Only available in ContentCreator. If a report plug-in is loaded in SiteArchitect and either its getItems or getDefaultItem methods provide a report item object implementing this interface, the SiteArchitect will silently ignore it.

This report item provides JavaScript that should be executed as the report item is activated and implements the interface ClientScriptProvidingReportItem<T>.

public class ExampleClientScriptProvidingReportItem implements ClientScriptProvidingReportItem<ExampleReportObject> {

public boolean isVisible(final ReportContext<ExampleReportObject> context) {
final ExampleReportObject reportEntryObject = context.getObject();
return reportEntryObject.toString() != null;
}

public boolean isEnabled(final ReportContext<ExampleReportObject> context) {
return true;
}

public String getLabel(final ReportContext<ExampleReportObject> context) {
return "Example Client Script-Providing Report Item";
}

public String getIconPath(final ReportContext<ExampleReportObject> context) {
return "example_report/example_clientscriptproviding_reportitem.png";
}

public String getScript(final ReportContext<ExampleReportObject> context) {
final ExampleReportObject reportEntryObject = context.getObject();
if (!reportEntryObject.isEmpty()) {
return "top.WE_API.Common.showMessage('" + reportEntryObject.toString() + "');";
} else {
return "top.WE_API.Common.showMessage('Report entry object is an empty string.');";
}
}

}

isVisible()

This method determines if the report item's button representation should be visible in the user interface.

Important The return value of this method only has effect upon report items shown as buttons attached to report list entries. A report plug-in's default report item is always assumed to be visible.

isEnabled()

This method determines if the report item should be enabled.

getLabel()

This method provides the text displayed in the report item's tool tip.

getIconPath()

This method provides the URL of an icon that should be displayed in this report item's button representation.

Important This method is only available in the interface WebeditExecutableReportPlugin. The return value of this method affects only report items shown in the ContentCreator.

getScript()

This method provides JavaScript code that should be evaluated as the report item is activated. The code may make use of ContentCreator's JavaScript API by accessing the top.WE_API object.

Important Unlike the execute() method in executable report item classes, the getScript() method is called while the report item's button is rendered in the user interface. Only the JavaScript code returned by this method is executed upon the button's activation. It is therefore essential that this method's code contain only non-obtrusive functionality related to assembling JavaScript code.

<< Kapitel „Transfer-Handler“

© 2005 - 2024 Crownpeak Technology GmbH | Alle Rechte vorbehalten. | FirstSpirit 2024.11 | Datenschutz