Support

Lorem ipsum dolor sit amet:

24h / 365days

We offer support for our customers

Mon - Fri 8:00am - 5:00pm (GMT +1)

Get in touch

Cybersteel Inc.
376-293 City Road, Suite 600
San Francisco, CA 94102

Have any questions?
+44 1234 567 890

Drop us a line
info@yourdomain.com

About us

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec.

5.1. Basic Script Reports

By default script reports are supposed to generate HTML. Thus, all we really need is to return HTML code as in the following example (note that we are using Groovy's multiline string feature here).

return """\
<html>
<head>
  <title>Hello World</title>
</head>
<body>
   <h1>Hello World</h1>
</body>
</html>
"""

Let us store this script as /bin/reports/report1.groovy. The next step is to define a script report. For this go to the report manager and create a new object of type script report. Provide a name and select the previously create script as script reference. After submitting the data you can execute the report as usual by simply double clicking on the item from the report manager. You should see that the report simply displays the content as defined by the HTML code. In contrast to other reports, there is no button for scheduling the report or exporting it. This is because we have not yet defined output formats for the report. For this go back to the script report in the report manager. Here you can define output Formats as a comma separated list. For example we can define

HTML, Plain

Submit the changes and reopen the report. You see that you now have two export options: HTML and Plain. However, both options produce the same, somewhat unexpected result. The browser displays the HTML code rather than the interpreted website. This is, because we have not specified the return type. For this, we need to return an object of type net.datenwerke.rs.core.service.reportmanager.engine.CompiledReport which besides the report's content contains information on, for example, the resulting mime type. Several predefined and simple to use objects are available:

  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledTextReportImpl} For simple text documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl} For html documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledDocxReport} For Microsoft Word documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledXlsxReport} For Microsoft Excel documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledJsonReport} For JSON documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledCsvReport} For comma separated value documents.
  • {net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledPdfReport} For PDF documents.

Thus, to make the browser render the output we could adapt our above script to

import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl

def report = """\
<html>
<head>
  <title>Hello World</title>
</head>
<body>
   <h1>Hello World</h1>
</body>
</html>
"""

return new CompiledHtmlReportImpl(report)

While the browser now renders the exported report properly, it also does so when using the export option Plain. To differentiate between the two output formats scripts have access to a predefined variable outputFormat. This variable contains the selected output format. Consider the following adaption

import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl

def report = """\
<html>
<head>
  <title>Hello World</title>
</head>
<body>
   <h1>Hello World</h1>
</body>
</html>
"""

if(outputFormat == 'plain')
	return 'Hello World'
return new CompiledHtmlReportImpl(report)

Note that, although the output format was defined as Plain, the script is given the output format in lower case and with leading and trailing whitespace removed. Now if you export the report to Plain you get the expected plain Hello World response, while an export to HTML will lead to a rendered Hello World response.

Zurück

InfoFabrik GmbH

Wir wollen, dass alle Unternehmen, Institutionen und Organisationen, die Daten auswerten, selbständig und zeitnah genau die Informationen erhalten, die sie für ein erfolgreiches Arbeiten benötigen.

InfoFabrik GmbH
Klingholzstr. 7
65189 Wiesbaden
Germany

+49 (0) 611 580 66 25

Kontaktieren Sie uns

Was ist die Summe aus 1 und 9?
Copyright 2007 - 2025 InfoFabrik GmbH. All Rights Reserved.
Einstellungen gespeichert
Datenschutzeinstellungen

Auf unserer Website setzen wir Cookies und andere Technologien ein. Während einige davon essenziell sind, dienen andere dazu, die Website zu verbessern und den Erfolg unserer Kampagnen zu bewerten. Bei der Nutzung unserer Website werden Daten verarbeitet, um Anzeigen und Inhalte zu messen. Weitere Informationen dazu finden Sie in unserer Datenschutzerklärung. Sie haben jederzeit die Möglichkeit, Ihre Einstellungen anzupassen oder zu widerrufen.

Auf unserer Webseite setzen wir und unsere Partner folgende Cookies ein:

PHPSESSID

Funktion: Dieser Cookie wird von PHP verwendet, um eine Sitzungs-ID zu speichern, die es ermöglicht, dass die Sitzungsdaten (wie Benutzereinstellungen oder Login-Informationen) zwischen den verschiedenen Seitenaufrufen derselben Sitzung erhalten bleiben. Er gewährleistet somit, dass alle auf PHP basierenden Funktionen der Website ordnungsgemäß arbeiten und der Benutzer als derselbe Benutzer innerhalb einer Sitzung erkannt wird.
Lebensdauer: Dieser Cookie hat eine Lebensdauer von der Dauer der Sitzung. Das bedeutet, er wird gelöscht, sobald der Browser geschlossen wird oder die Sitzung abläuft.

csrf_https-contao_csrf_token

Funktion: Dieser Cookie wird verwendet, um vor Cross-Site Request Forgery (CSRF) Angriffen zu schützen. CSRF ist eine Sicherheitslücke, bei der Angreifer durch unautorisierte Kommandos die Aktionen eines authentifizierten Benutzers ausführen könnten. Der Cookie speichert ein Token, das mit jeder sicherheitsrelevanten Anfrage verglichen wird, um sicherzustellen, dass die Anfrage tatsächlich von einem authentifizierten Benutzer stammt.
Lebensdauer: Dieser Cookie hat eine Lebensdauer von der Dauer der Sitzung. Er wird ebenfalls gelöscht, sobald der Browser geschlossen wird oder die Sitzung abläuft.
You are using an outdated browser. The website may not be displayed correctly. Close
Gehe zu: Bedienhilfen-Einstellungen