Class HTMLUtils

java.lang.Object
com.groiss.wf.html.HTMLUtils

public class HTMLUtils extends Object
Some utility methods for building HTML GUIs
  • Field Details

    • SEARCH_TERM_SPLIT_PATTERN

      public static final Pattern SEARCH_TERM_SPLIT_PATTERN
    • FORMAT_FIELDS_AS_COMPONENT

      public static final String FORMAT_FIELDS_AS_COMPONENT
      See Also:
  • Constructor Details

    • HTMLUtils

      public HTMLUtils()
  • Method Details

    • selectList

      public static Page selectList(HttpServletRequest req) throws Exception
      Show a list of objects for selection, best for use in a popup.
      Throws:
      Exception
    • selectList2

      public static Page selectList2(HttpServletRequest req) throws Exception
      Show a list of objects for selection, best for use in a popup. Objects are shown in a HTML select list.
      Throws:
      Exception
    • getSelectList2

      public static Collection<Pair<String,String>> getSelectList2(HttpServletRequest req) throws Exception
      Throws:
      Exception
    • getSelectList2

      public static Collection<Pair<String,String>> getSelectList2(Map<String,String> params) throws Exception
      Throws:
      Exception
    • getParameters

      public static Map<String,String> getParameters(HttpServletRequest req)
      read the parameters from node and from request
    • getSelectObjectById

      public static Pair<String,String> getSelectObjectById(long oid, Map<String,String> params) throws Exception
      Throws:
      Exception
    • getObjects

      public static List<Persistent> getObjects(Class<Persistent> c, Map<String,String> params, boolean isTable) throws Exception
      Throws:
      Exception
    • getPreparedStatementCondition

      public static String getPreparedStatementCondition(String cond, List<Object> values, String param, String types)
    • getStandardSearchIdOfClass

      public static String getStandardSearchIdOfClass(Class<?> c)
    • getSearchCondition

      public static Pair<String,List<Object>> getSearchCondition(Persistent o, String searchAttrs, String searchString)
      builds a condition for querying the given Persistent uses the global setting for smartSearch
      Parameters:
      o -
      searchAttrs - the attrs, comma separated
      searchString - the search-string
      Returns:
    • getSearchCondition

      public static Pair<String,List<Object>> getSearchCondition(Persistent o, String searchAttrs, String searchString, boolean smartSearch)
      builds a condition querying the given Persistent if smartSearch is true, the given searchString will be splitted, and searched in each searchAttr on it's own
      Parameters:
      o -
      searchAttrs -
      searchString -
      smartSearch - use smartSearch?
      Returns:
    • getWorklist

      public static TableModel getWorklist(HttpServletRequest req, String id)
      Return a worklist as table model.
      Parameters:
      req - the HTTP request
      id - the id of the worklist, for example standard.wl
      Returns:
      the worklist as table model
    • getRunningSteps

      public static String getRunningSteps(ProcessInstance pi, String delim, boolean includeLongRunning)
      Returns a string containing the active step of the given process with agents and step-name
      Parameters:
      pi - a process instance
      delim - a delimiter, for example ", "
      includeLongRunning - if true, not only interactive steps are shown but also batch steps, webservice calls, etc.
      Returns:
      a string containing the active steps
    • showForm

      public static Page showForm(HttpServletRequest req) throws Exception
      Throws:
      Exception
    • showForm

      public static Page showForm(HttpServletRequest r, ActivityInstance ai, String formid, int mode) throws Exception
      Show a process form.
      Parameters:
      r - the request
      ai - the current activity
      formid - the id of the form in the process definition
      mode - the mode
      Throws:
      Exception
    • showForm

      public static Page showForm(DMSForm form, List<Component> buttons, String action, FormContext ctx) throws Exception
      Show a form.
      Parameters:
      form - the form object
      buttons - a list of components, buttons are shown on the bottom of the form, hidden fields are included in the form.
      action - the submit action (Hint: If a XForm is used, the submit action must be defined at the Submit button!)
      ctx - the form context
      Returns:
      a HTMLPage for HTML-forms, else an XHTMLPage
      Throws:
      Exception
    • refreshForm

      public static Page refreshForm(HttpServletRequest req) throws Exception
      Throws:
      Exception
    • showPrintForm

      public Page showPrintForm(HttpServletRequest req) throws Exception
      This method returns a page containing a print version of a form. It requires that the req contains a parameter 'object' with the classname:oid of the form. The method removes all buttons and adds a header and footer to the page.
      Throws:
      Exception
    • showPdfForm

      public void showPdfForm(HttpServletRequest req, HttpServletResponse res) throws Exception
      This methods creates a pdf from a form. The form is first created in VIEW_TEXT mode (with the permissions of the current activity if parameter task contains its oid). The method only works with XForms and XHTMLForms.
      Parameters:
      req - parameter object references the form
      res - receives the pdf
      Throws:
      Exception
    • showPdfForm

      public static void showPdfForm(DMSForm form, FormContext ctx, OutputStream os, String addr, Locale l) throws Exception
      Create a pdf out of the form.
      Parameters:
      form - a form object
      ctx - the form context (may define visibilities)
      os - on this stream the pdf is written
      addr - base address if the html contains links to external resources, for example images
      l - the locale used for internationalization
      Throws:
      Exception
    • convertToPDF

      public static void convertToPDF(XHTMLPage p, OutputStream os, String addr, Locale l) throws Exception
      Create a pdf out of the form. Note, that some styles are changed before creating the pdf:
      • radio buttons and checkboxes are replaced by images
      • textarea:height is set to auto (don't set the height in a style attribute, set it in a class), white-space to pre-wrap; a width attribute must be set in the page, preferably by using "@media print" directive.
      Parameters:
      p - an XHTML Page
      os - on this stream the pdf is written
      addr - base address if the html contains links to external resources, for example images
      l - the locale used for internationalization
      Throws:
      Exception
    • pdf

      public void pdf(HttpServletRequest req, HttpServletResponse res) throws Exception
      Throws:
      Exception
    • showProcessDetails

      public static Page showProcessDetails(HttpServletRequest req) throws Exception
      Show the process details, designed for opened in a popup window.
      Parameters:
      req - the request must contain a parameter "pi" of form classname:oid referencing a process instance object. Optional request parameter "selectedTab" of form "xmlid.nodeid" (e.g. admin.documents) determines the selected tab.
      Throws:
      Exception
    • getObject

      public static Persistent getObject(JSONObject obj)
    • taskProps

      public static String taskProps(ActivityInstance ai)
      Returns a description for an activity instance with the following pattern: Id: <id of the process instance> Task: <name of task or step name> Subject: <process instance subject>
      Parameters:
      ai - - the activity instance
    • getObject

      public static <T extends Persistent> T getObject(HttpServletRequest req)
      This method returns a persistent object when the request contains a parameter "object" with a value in the form <classname>:<oid>. The method returns null if no such parameter is present or the object is not in the database. if the oid is 0 it returrns a new instance of the class.
      Parameters:
      req -
      Returns:
      a persistent object or null
    • getObjectWithViewCheck

      public static <T extends Persistent> T getObjectWithViewCheck(HttpServletRequest req)
      Same as getObject, but checks view right on the object.
    • getObject

      public static <T extends Persistent> T getObject(HttpServletRequest req, String key)
    • getDocumentsLink

      public static Link getDocumentsLink(ActivityInstance si)
      Returns:
      a link to the document folder
    • getNotesLink

      public static Link getNotesLink(ActivityInstance ai)
      Returns:
      a link to the notes of a process
    • showSubformLink

      public static Link showSubformLink(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler)
    • showSubformLink

      public static Link showSubformLink(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions)
    • showSubformLink

      public static Link showSubformLink(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction)
    • showSubformLink

      public static Link showSubformLink(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction, String page)
    • showSubformLink

      public static Link showSubformLink(Persistent obj, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction, String page)
    • insertSubTable

      public static void insertSubTable(Element el, DMSForm mainform, short mode) throws Exception
      Insert a subform table in an XHTMLPage.
      Parameters:
      el - an jdom-element in a XHMTL page. The element will be modified and the table is added as sub-element.
      mainform - the main form
      mode - the mode for showing the table, RemoteWfEngine.INVISIBLE, READ_ONLY, READ_WRITE, NO_ADDDEL
      Throws:
      Exception
    • insertSubTable

      public static void insertSubTable(Element el, DMSForm mainform, short mode, ActivityInstance ai) throws Exception
      Insert a subform table in an XHTMLPage.
      Parameters:
      el - an jdom-element in a XHMTL page. The element will be modified and the table is added as sub-element.
      mainform - the main form
      mode - the mode for showing the table, RemoteWfEngine.INVISIBLE, READ_ONLY, READ_WRITE, NO_ADDDEL
      ai - context activity instance, may be used in subtables table event handler
      Throws:
      Exception
    • getObjectList

      public static <T extends Persistent> List<T> getObjectList(HttpServletRequest req, String key)
      Get list of objects (from multiple selection list) stored in request under key
      Parameters:
      req -
      key -
    • getObjectListForComponent

      public static List<Pair<String,String>> getObjectListForComponent(List<? extends Persistent> l)
    • getDisplayValue

      public static String getDisplayValue(DMSForm form, String field)
      returns the given field's display value this can be:
      Parameters:
      form - the form
      field - the field, the text will be returned
      Returns:
      the fields display value or null if no text was found
    • showFormTable

      public Page showFormTable(HttpServletRequest req)
      Show a Form table in its own window or iframe.
      Parameters:
      req - parameters: showToolbar: true | false, hideCloseButton: true | false, nodeid: define the node by specifying the id
    • showPopup

      public Page showPopup(HttpServletRequest req) throws Exception
      Shows a window with an iframe and a close button below. Iframe src is set to the value of the url parameter.
      Parameters:
      req - prameter url is used as iframe source.
      Throws:
      Exception
    • showWorklist

      @Deprecated public static void showWorklist(HttpServletRequest r, HttpServletResponse res, Application appl, int type, String worklist, String functions) throws Exception
      Deprecated.
      sends the worklist to the browser.
      Parameters:
      r - the HTTP request
      res - the HTTP response
      appl - the application
      type - the type: 0..user, 1..role, 2..suspension list
      worklist - a worklist implementation (implements com.groiss.wf.html.Worklist)
      functions - a space-separated list of function ids
      Throws:
      Exception
    • toJSON

      @Deprecated(since="10.0", forRemoval=true) public static JSONObject toJSON(Persistent obj)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      obj -
      Returns:
    • getDocumentsLink

      @Deprecated(since="11.0", forRemoval=true) public static Link getDocumentsLink(ActivityInstance si, String comingFrom)
      Deprecated, for removal: This API element is subject to removal in a future version.
      as parameter 'comingFrom' is not supported anymore, use getDocumentsLink(ActivityInstance) instead
      Parameters:
      comingFrom - the url for the back button in the document table
      Returns:
      a link to the document folder
    • showEmptyForm

      @Deprecated public static Page showEmptyForm(DMSForm f, String buttons, HttpServletRequest req) throws Exception
      Deprecated.
      Throws:
      Exception
      See Also:
    • showForm

      @Deprecated public static Page showForm(HttpServletRequest r, ActivityInstance ai, String formid, int mode, String buttons) throws Exception
      Deprecated.
      Throws:
      Exception
      See Also:
    • selectTable

      @Deprecated(since="11.0", forRemoval=true) public static Page selectTable(HttpServletRequest req) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      same as selectList.
      Throws:
      Exception
    • agentSelectList

      @Deprecated(since="8.0", forRemoval=true) public Page agentSelectList(HttpServletRequest req) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      use ep/widget/smartclient/form/ObjectInputField}
      Throws:
      Exception
    • selectUserOrRole

      @Deprecated(since="11.0", forRemoval=true) public static Page selectUserOrRole(HttpServletRequest req) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      use ep/widget/smartclient/form/ObjectInputField}
      Throws:
      Exception
    • roleList

      @Deprecated(since="11.0", forRemoval=true) public Page roleList(HttpServletRequest request) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      The method is used in selectUserOrRole
      Throws:
      Exception
    • userList

      @Deprecated(since="11.0", forRemoval=true) public Page userList(HttpServletRequest r) throws Exception
      Deprecated, for removal: This API element is subject to removal in a future version.
      The method is used in selectUserOrRole
      Throws:
      Exception