Startseite / Plugin-Entwicklung / Universelle Erweiterungen / Reports (veraltet) / Codebeispiel / Daten-Renderer

Kapitel „Transfer-Handler“ >>

<< Kapitel „Data Provider“

The Data Renderer

Access API documentation: DataRenderer<T>

Data renderer classes define report entries' representation in the client user interface. Based on an indiviaul report entry object, the data renderer determines icon, title, descriptive text, and thumbnail to be displayed in the report's result list.

ContentCreator also supports a fly-out that is displayed as the mouse pointer hovers over a single report result entry and may include an HTML snippet with more detailed information about the result entry.

Code Example

This second-tier class is used to adapt information from the object type(s) this report uses into various forms that will be used in report list snippets. It implements the interface DataRenderer<T> and has no direct representation in FirstSpirit client user interfaces; rather, clients use the data provided by this class' methods to render individual report result snippets.

public class ExampleDataRenderer implements DataRenderer<ExampleReportObject> {

// BaseContect object for internal persistence in this class.
final BaseContext _context;

ExampleReportPluginRenderer(final BaseContext context) {
_context = context;
}

public Image<?> getIcon(ExampleReportObject object) {
if (_context.is(de.espirit.firstspirit.access.BaseContext.Env.WEBEDIT)) {
// Return a ContentCreator-compatible icon.
return Image.Factory.fromUrl("webclient_examples/report_item_thumbnail.png");
} else {
// Return a SiteArchitect-compatible icon -- since this method is @nullable, we'll return nothing for now.
return null;
}
}

public String getTitle(ExampleReportObject object) {
return object.toString();
}

public String getDescription(ExampleReportObject object) {
return "Text length: " + object.toString().length() + " characters";
}

public Image<?> getThumbnail(ExampleReportObject object) {
return null;
}

public String getDetails(ExampleReportObject object) {
return "<b>This report entry contains a string:</b><br/><br/>" + object.toString();
}
}

getIcon()

 

The method getIcon() returns an icon to be used for this report entry. This icon will be displayed next to the report entry's title and is intended to provide a distinctive feature for reports that display several different entry types (e.g. a report that displays files of different types such as audio, video and images - in this case, it is reasonable to return a different icon for each file type).

Image Factory for Client-Specific Icons

Due to the cross-client nature of FirstSpirit report plug-ins, icon objects for reports and report entries are generated using a factory, Image$Factory.

For the ContentCreator, Image.Factory.fromUrl(String) should be used. The String parameter provides a path, including file name, relative to the root of the project-specific ContentCreator web application.

For the SiteArchitect, Image.Factory.fromIcon(javax.swing.Icon) should be used.

getTitle()

This method returns a string that will be displayed in bold font in the report entry snippet's first line of text.

Though developers are free to choose any string data, it is recommended to provide a short, concise phrase from the object's contents or attributes that will allow users to quickly identify this object in a report list.

getDescription()

The string returned by this method will be displayed in regular font weight in the report entry snippet's second line of text.

The description field is intended as a terse, abstract-like reminder of the object's contents and will be truncated to fit in one line.

getThumbnail()

This method determines if a thumbnail (e.g. a small preview version of an image file represented by the report entry) should be displayed, and if so, returns such a thumbnail as an Image object.

The thumbnail graphic will be displayed inside the object's snippet representation in the report list, aligned flush right. If a sensible thumbnail choice is not available for the currently rendered object, this method may return null; in this case, the snippet will not display a thumbnail.

Image Factory for Client-Specific Icons

Due to the cross-client nature of FirstSpirit report plug-ins, icon objects for reports and report entries are generated using a factory, Image$Factory.

For the ContentCreator, Image.Factory.fromUrl(String) should be used. The String parameter provides a path, including file name, relative to the root of the project-specific ContentCreator web application.

For the SiteArchitect, Image.Factory.fromIcon(javax.swing.Icon) should be used.

getDetails()

Details flyout for a report entry in ContentCreator

This method returns HTML code that contains additional information about the associated report entry. This additional information is displayed as a fly-out while the mouse pointer hovers above the report entry snippet.

Report entry details are entirely optional; this method may return null if display of additional entry data is not desired or not available.

Important Only used in ContentCreator.

Kapitel „Transfer-Handler“ >>

<< Kapitel „Data Provider“

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