Class JasperReportBaseAction

All Implemented Interfaces:
IAction, IChangeModeAction, IForwardAction, IModelAction, IModuleContextAction, IRequestAction

public abstract class JasperReportBaseAction extends ViewBaseAction implements IForwardAction, IModelAction
To generate your custom Jasper Report.

You only need to overwrite the abstract methods.

Author:
Javier Paniza, Daniel GarcĂ­a Salas
  • Field Details

    • PDF

      public static String PDF
    • EXCEL

      public static String EXCEL
    • RTF

      public static String RTF
    • ODT

      public static String ODT
  • Constructor Details

    • JasperReportBaseAction

      public JasperReportBaseAction()
  • Method Details

    • getDataSource

      protected abstract net.sf.jasperreports.engine.JRDataSource getDataSource() throws Exception
      Data to print.

      If return null then a JDBC connection is sent to JasperReport, this is for the case of a SQL inside JasperReport design.

      Throws:
      Exception
    • getJRXML

      protected abstract String getJRXML() throws Exception
      The name of the XML with the JasperReports design.

      If it is a relative path (as reports/myreport.jrxml has to be in classpath. If it is a absolute path (as /home/java/reports/myreport.xml or C:\\JAVA\\REPORTS\MYREPORT.JRXML then it look at the file system.

      Throws:
      Exception
    • getParameters

      protected abstract Map getParameters() throws Exception
      Parameters to send to report.
      Throws:
      Exception
    • getFormat

      public String getFormat() throws Exception
      Output report format, it can be 'pdf' or 'excel'.

      Throws:
      Exception
    • setFormat

      public void setFormat(String format) throws Exception
      Output report format, it can be 'pdf', 'excel' or 'rtf'.

      Throws:
      Exception
    • execute

      public void execute() throws Exception
      Specified by:
      execute in interface IAction
      Throws:
      Exception
    • getForwardURI

      public String getForwardURI()
      Description copied from interface: IForwardAction
      The URI to go.

      If it starts with "http://" or "https://" the action will forward to the absolute URL in internet (since v4m1). Since 7.1 using "javascript:" as prefix to execute JavaScript is not allowed. Since 4.0.1 if it starts with "javascript:" the corresponding code will executed by the browser. Since 5.9 you should use IJavaScriptPostAction to execute JavaScript because IForwardAction with javascript: does not update the page before executing the JavaScript, but executes the JavaScript instead. If it returns null the forwarding is not done.

      Specified by:
      getForwardURI in interface IForwardAction
    • inNewWindow

      public boolean inNewWindow()
      Specified by:
      inNewWindow in interface IForwardAction
    • setModel

      public void setModel(String modelName)
      Specified by:
      setModel in interface IModelAction
    • getFileName

      public String getFileName()
    • setFileName

      public void setFileName(String fileName)