Class HtmlReport

java.lang.Object
org.apache.ofbiz.htmlreport.AbstractReport
org.apache.ofbiz.htmlreport.HtmlReport
All Implemented Interfaces:
InterfaceReport
Direct Known Subclasses:
AbstractHtmlReport

public class HtmlReport extends AbstractReport
HTML report output to be used in report.ftl.

  • Field Details

    • DELIMITER_RESOURCES

      public static final String DELIMITER_RESOURCES
      The delimiter that is used in the RESOURCE list request parameter.
      See Also:
    • PARAM_RESOURCELIST

      public static final String PARAM_RESOURCELIST
      Request parameter name for the RESOURCE list.
      See Also:
    • LINEBREAK

      protected static final String LINEBREAK
      Constant for a HTML linebreak with added "real" line break.
      See Also:
    • LINEBREAK_TRADITIONAL

      protected static final String LINEBREAK_TRADITIONAL
      Constant for a HTML linebreak with added "real" line break- traditional style for report threads that still use XML templates for their output.
      See Also:
    • HTML_END

      public static final int HTML_END
      Helper variable to deliver the html end part.
      See Also:
    • HTML_START

      public static final int HTML_START
      Helper variable to deliver the html start part.
      See Also:
    • BUTTON_OK

      public static final int BUTTON_OK
      Constant for the "OK" button in the build button methods.
      See Also:
    • BUTTON_CANCEL

      public static final int BUTTON_CANCEL
      Constant for the "Cancel" button in the build button methods.
      See Also:
    • BUTTON_CLOSE

      public static final int BUTTON_CLOSE
      Constant for the "Close" button in the build button methods.
      See Also:
    • BUTTON_ADVANCED

      public static final int BUTTON_ADVANCED
      Constant for the "Advanced" button in the build button methods.
      See Also:
    • BUTTON_SET

      public static final int BUTTON_SET
      Constant for the "Set" button in the build button methods.
      See Also:
    • BUTTON_DETAILS

      public static final int BUTTON_DETAILS
      Constant for the "Details" button in the build button methods.
      See Also:
    • BUTTON_OK_NO_SUBMIT

      public static final int BUTTON_OK_NO_SUBMIT
      Constant for the "OK" button in the build button methods (without form submission).
      See Also:
    • BUTTON_EDIT

      public static final int BUTTON_EDIT
      Constant for the "Edit" button in the build button methods (same function as "Ok" button but different text on button.
      See Also:
    • BUTTON_DISCARD

      public static final int BUTTON_DISCARD
      Constant for the "Discard" button in the build button methods (same function as "Cancel" button but different text on button.
      See Also:
    • BUTTON_BACK

      public static final int BUTTON_BACK
      Constant for the "Back" button in the build button methods.
      See Also:
    • BUTTON_CONTINUE

      public static final int BUTTON_CONTINUE
      Constant for the "Continue" button in the build button methods.
      See Also:
    • BUTTON_DOWNLOAD

      public static final int BUTTON_DOWNLOAD
      Constant for the "Download" button in the build button methods.
      See Also:
    • DIALOG_BACK

      public static final String DIALOG_BACK
      Request parameter value for the action: back.
      See Also:
    • DIALOG_CANCEL

      public static final String DIALOG_CANCEL
      Request parameter value for the action: cancel.
      See Also:
    • DIALOG_CONTINUE

      public static final String DIALOG_CONTINUE
      Request parameter value for the action: continue.
      See Also:
    • DIALOG_SET

      public static final String DIALOG_SET
      Request parameter value for the action: set.
      See Also:
    • DIALOG_URI

      public static final String DIALOG_URI
      See Also:
    • FORM_URI

      public static final String FORM_URI
      See Also:
  • Constructor Details

    • HtmlReport

      public HtmlReport(HttpServletRequest request, HttpServletResponse response)
      Constructs a new report using the provided locale for the output language.

      Parameters:
      request - HttpServletRequest
      response - HttpServletResponse
    • HtmlReport

      public HtmlReport(HttpServletRequest request, HttpServletResponse response, boolean writeHtml, boolean isTransient)
      Constructs a new report using the provided locale for the output language.

      Parameters:
      request - HttpServletRequest
      response - HttpServletResponse
      writeHtml - if true, this report should generate HTML instead of JavaScript output
      isTransient - If set to true nothing is kept in memory
  • Method Details

    • getInstance

      public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response)
    • getInstance

      public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response, boolean writeHtml, boolean isTransient)
    • getInstance

      public static HtmlReport getInstance(HttpServletRequest request, HttpServletResponse response, boolean writeHtml, boolean isTransient, String logFileName)
    • getParamAction

      public String getParamAction(HttpServletRequest request)
      Gets param action.
      Parameters:
      request - the request
      Returns:
      the param action
    • setParamAction

      public void setParamAction(String action)
      Sets param action.
      Parameters:
      action - the action
    • setParamThread

      public void setParamThread(String name)
      Sets param thread.
      Parameters:
      name - the name
    • getReportUpdate

      public String getReportUpdate()
      Description copied from interface: InterfaceReport
      Updates this report, this processes all new output added since the last call to this method.

      This is only required in case the output is written to a HTML page, if the shell output is used, this will just return an empty String.

      Returns:
      new elements that have been added to the report and not yet processed.
    • isWriteHtml

      public boolean isWriteHtml()
      Returns if the report writes html or javascript code.

      Returns:
      true if the report writes html, and false if the report writes javascript code
    • print

      public void print(String value, int format)
      Description copied from class: AbstractReport
      Prints a String to the report, using the indicated formatting.

      Use the contants starting with FORMAT from this interface to indicate which formatting to use.

      Specified by:
      print in interface InterfaceReport
      Specified by:
      print in class AbstractReport
      Parameters:
      value - the message container to add
      format - the formatting to use for the output
    • println

      public void println()
      Description copied from interface: InterfaceReport
      Adds a line break to the report.

    • println

      public void println(Throwable t)
      Description copied from interface: InterfaceReport
      Adds an Exception to the report, ensuring that the Exception content is processed to generate a valid output esp. for HTML pages.

      The exception will be stored and the output will later be processed in a special way.

      Parameters:
      t - the exception to add
    • getLineBreak

      protected String getLineBreak()
      Returns the correct line break notation depending on the output style of this report.
      Returns:
      the correct line break notation
    • printMessageWithParam

      public void printMessageWithParam(String uiLabel, Object param)
      Description copied from interface: InterfaceReport
      Prints a localized message followed by a parameter and dots to the report.

      Parameters:
      uiLabel - the Message to add
      param - the Parameter to add
    • printMessageWithParam

      public void printMessageWithParam(int m, int n, String uiLabel, Object param)
      Description copied from interface: InterfaceReport
      Convenience method to print a localized message, followed by a parameter and dots to the report.

      The output follows the pattern: ( 3 / 8 ) Deleting filename.txt ...

      Parameters:
      m - the number of the report output
      n - the total number of report outputs
      uiLabel - the Message to add
      param - the Parameter to add
    • htmlStart

      public String htmlStart()
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Returns:
      the start html of the page
    • htmlStart

      public String htmlStart(boolean loadStyles)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Parameters:
      loadStyles - if true, the defaul style sheet will be loaded
      Returns:
      the start html of the page
    • pageHtml

      public String pageHtml(int segment, boolean loadStyles)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Parameters:
      segment - the HTML segment (START / END)
      loadStyles - if true, the defaul style sheet will be loaded
      Returns:
      the start html of the page
    • dialogScriptSubmit

      public String dialogScriptSubmit()
      Builds the standard javascript for submitting the dialog.

      Returns:
      the standard javascript for submitting the dialog
    • isAlive

      public boolean isAlive(HttpServletRequest request)
      Returns true if the report Thread is still alive (i.e. running), false otherwise.

      Returns:
      true if the report Thread is still alive
    • getParamThread

      public String getParamThread(HttpServletRequest request)
      Returns the thread parameter value.

      Returns:
      the thread parameter value
    • getParamThreadHasNext

      public String getParamThreadHasNext(HttpServletRequest request)
      Returns the threadhasnext parameter value.

      Returns:
      the threadhasnext parameter value
    • bodyStart

      public String bodyStart(String className, String parameters)
      Builds the start html of the body.

      Parameters:
      className - optional class attribute to add to the body tag
      parameters - optional parameters to add to the body tag
      Returns:
      the start html of the body
    • pageBody

      public String pageBody(int segment, String className, String parameters)
      Builds the html of the body.

      Parameters:
      segment - the HTML segment (START / END)
      className - optional class attribute to add to the body tag
      parameters - optional parameters to add to the body tag
      Returns:
      the html of the body
    • bodyEnd

      public String bodyEnd()
      Builds the end html of the body.

      Returns:
      the end html of the body
    • htmlEnd

      public String htmlEnd()
      Builds the end html of the page.

      Returns:
      the end html of the page
    • pageHtml

      public String pageHtml(int segment, String title)
      Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type.

      Parameters:
      segment - the HTML segment (START / END)
      title - the title of the page, if null no title tag is inserted
      Returns:
      the default html for a workplace page
    • pageHtmlStyle

      public String pageHtmlStyle(int segment, String title, String stylesheet)
      Returns the default html for a workplace page, including setting of DOCTYPE and inserting a header with the content-type, allowing the selection of an individual style sheet.

      Parameters:
      segment - the HTML segment (START / END)
      title - the title of the page, if null no title tag is inserted
      stylesheet - the used style sheet, if null the default stylesheet 'workplace.css' is inserted
      Returns:
      the default html for a workplace page
    • dialogStart

      public String dialogStart()
      Returns the start html for the outer dialog window border.
      Returns:
      the start html for the outer dialog window border
    • dialog

      public String dialog(int segment, String attributes)
      Builds the outer dialog window border.
      Parameters:
      segment - the HTML segment (START / END)
      attributes - optional additional attributes for the opening dialog table
      Returns:
      a dialog window start / end segment
    • dialogContentStart

      public String dialogContentStart(String title)
      Returns the start html for the content area of the dialog window.

      Parameters:
      title - the title for the dialog
      Returns:
      the start html for the content area of the dialog window
    • dialogContent

      public String dialogContent(int segment, String title)
      Builds the content area of the dialog window.

      Parameters:
      segment - the HTML segment (START / END)
      title - the title String for the dialog window
      Returns:
      a content area start / end segment
    • dialogHead

      public String dialogHead(String title)
      Builds the title of the dialog window.

      Parameters:
      title - the title String for the dialog window
      Returns:
      the HTML title String for the dialog window
    • getParamTitle

      public String getParamTitle(HttpServletRequest request)
      Returns the value of the title parameter, or null if this parameter was not provided.

      This parameter is used to build the title of the dialog. It is a parameter so that the title can be passed to included elements.

      Returns:
      the value of the title parameter
    • paramsAsHidden

      public String paramsAsHidden(HttpServletRequest request)
      Returns all initialized parameters of the current workplace class as hidden field tags that can be inserted in a form.

      Returns:
      all initialized parameters of the current workplace class as hidden field tags that can be inserted in a html form
    • paramsAsHidden

      public String paramsAsHidden(HttpServletRequest request, Collection<?> excludes)
      Returns all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form.

      Parameters:
      excludes - the parameters to exclude
      Returns:
      all initialized parameters of the current workplace class that are not in the given exclusion list as hidden field tags that can be inserted in a form
    • paramValues

      protected Map<String,Object> paramValues(HttpServletRequest request)
      Returns the values of all parameter methods of this workplace class instance.

      Returns:
      the values of all parameter methods of this workplace class instance
    • reportIntroductionText

      public String reportIntroductionText()
      Returns an optional introduction text to be displayed above the report output.

      Returns:
      an optional introduction text
    • reportConclusionText

      public String reportConclusionText()
      Returns an optional conclusion text to be displayed below the report output.

      Returns:
      an optional conclusion text
    • dialogContentEnd

      public String dialogContentEnd()
      Returns the end html for the content area of the dialog window.

      Returns:
      the end html for the content area of the dialog window
    • dialogButtonsContinue

      public String dialogButtonsContinue(String okAttrs, String cancelAttrs)
      Builds a button row with an "Ok" and a "Cancel" button.

      This row is displayed when the first report is running.

      Parameters:
      okAttrs - optional attributes for the ok button
      cancelAttrs - optional attributes for the cancel button
      Returns:
      the button row
    • dialogButtonsOkCancel

      public String dialogButtonsOkCancel(HttpServletRequest request, String okAttrs, String cancelAttrs)
      Builds a button row with an "OK" and a "Cancel" button.

      This row is used when a single report is running or after the first report has finished.

      Parameters:
      okAttrs - optional attributes for the ok button
      cancelAttrs - optional attributes for the cancel button
      Returns:
      the button row
    • dialogButtonsOkCancelDownload

      public String dialogButtonsOkCancelDownload(HttpServletRequest request, String okAttrs, String cancelAttrs, String downloadAttrs)
      Builds a button row with an "OK", a "Cancel" and a "Download" button.

      This row is used when a single report is running or after the first report has finished.

      Parameters:
      okAttrs - optional attributes for the ok button
      cancelAttrs - optional attributes for the cancel button
      downloadAttrs - optional attributes for the download button
      Returns:
      the button row
    • dialogButtons

      public String dialogButtons(int[] buttons, String[] attributes)
      Builds the html for the button row under the dialog content area, including buttons.

      Parameters:
      buttons - array of constants of which buttons to include in the row
      attributes - array of Strings for additional button attributes
      Returns:
      the html for the button row under the dialog content area, including buttons
    • dialogButtonRow

      public String dialogButtonRow(int segment)
      Builds the button row under the dialog content area without the buttons.

      Parameters:
      segment - the HTML segment (START / END)
      Returns:
      the button row start / end segment
    • dialogButtonsHtml

      protected void dialogButtonsHtml(StringBuffer result, int button, String attribute)
      Renders the HTML for a single input button of a specified type.

      Parameters:
      result - a string buffer where the rendered HTML gets appended to
      button - a integer key to identify the button
      attribute - an optional string with possible tag attributes, or null
    • appendDelimiter

      protected String appendDelimiter(String attribute)
      Appends a space char. between tag attributes.

      Parameters:
      attribute - a tag attribute
      Returns:
      the tag attribute with a leading space char
    • isMultiOperation

      public boolean isMultiOperation(HttpServletRequest request)
      Returns true if the dialog operation has to be performed on multiple resources.

      Returns:
      true if the dialog operation has to be performed on multiple resources, otherwise false
    • getResourceList

      public List<String> getResourceList(HttpServletRequest request)
      Returns the resources that are defined for the dialog operation. For single RESOURCE operations, the list contains one item: the RESOURCE name found in the request parameter value of the "RESOURCE" parameter.
      Returns:
      the resources that are defined for the dialog operation
    • getParamResourcelist

      public String getParamResourcelist(HttpServletRequest request)
      Returns the value of the RESOURCE list parameter, or null if the parameter is not provided.

      This parameter selects the resources to perform operations on.

      Returns:
      the value of the RESOURCE list parameter or null, if the parameter is not provided
    • getParamResource

      public String getParamResource(HttpServletRequest request)
      Returns the value of the file parameter, or null if this parameter was not provided.

      The file parameter selects the file on which the dialog action is to be performed.

      Returns:
      the value of the file parameter
    • getParamRefreshWorkplace

      public String getParamRefreshWorkplace()
      Returns if the workplace must be refreshed.

      Returns:
      "true" if the workplace must be refreshed.
    • getParamReportContinueKey

      public String getParamReportContinueKey()
      Returns the key name which contains the localized message for the continue checkbox.

      Returns:
      the key name which contains the localized message for the continue checkbox
    • getResourceListAsParam

      public String getResourceListAsParam(HttpServletRequest request)
      Returns the value of the resourcelist parameter in form of a String separated with DELIMITER_RESOURCES, or the value of the RESOURCE parameter if the first parameter is not provided (no multiple choice has been done.

      This may be used for jsps as value for the parameter for resources PARAM_RESOURCELIST.

      Returns:
      the value of the resourcelist parameter or null, if the parameter is not provided
    • dialogEnd

      public String dialogEnd()
      Returns the end html for the outer dialog window border.

      Returns:
      the end html for the outer dialog window border
    • getDialogRealUri

      public String getDialogRealUri(HttpServletRequest request)
      Returns the http URI of the current dialog, to be used as value for the "action" attribute of a html form.

      This URI is the real one.

      Returns:
      the http URI of the current dialog
    • setFormRealUri

      public void setFormRealUri(HttpServletRequest request, String formUri)
      Set the report form uri.
      Parameters:
      request -
      formUri -
    • getFormRealUri

      public String getFormRealUri(HttpServletRequest request)
      Get the report form uri.
      Parameters:
      request -
      Returns:
    • addLogFile

      public void addLogFile(String logFileName)
      Description copied from interface: InterfaceReport
      Add a log file to the report.
    • closeLogFile

      public String closeLogFile()
      Description copied from interface: InterfaceReport
      Close log file if necessary.
    • getLogFileName

      public String getLogFileName()
      Gets log file name.
      Returns:
      the log file name
    • getSequenceNum

      public long getSequenceNum()
    • setSequenceNum

      public void setSequenceNum(long sequenceNum)
      Description copied from interface: InterfaceReport
      Set log's sequence number.