Package com.groiss.wf.html
Class HTMLUtils
java.lang.Object
com.groiss.wf.html.HTMLUtils
Some utility methods for building HTML GUIs
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Exception is thrown in case the total count of entries exceeds the configured maximum. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.use ep/widget/smartclient/form/ObjectInputField}static void
convertToPDF
(XHTMLPage p, OutputStream os, String addr, Locale l) Create a pdf out of the form.static String
getDisplayValue
(DMSForm form, String field) returns the given field's display value this can be: for dates: can be either aCalUtil.showDate(Object)
or theCalUtil.showDateTime(Object)
representation of the value for selectlist-values: the localized display-value of the selectlist-option for decimal fields: the formatted value usingSettings.getDecimalFormatter()
with the max. fraction and integer digits set as defined for the fieldstatic Link
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, usegetDocumentsLink(ActivityInstance)
insteadstatic Link
static <T extends Persistent>
TThis method returns a persistent object when the request contains a parameter "object" with a value in the form <classname>:<oid>.static <T extends Persistent>
TgetObject
(HttpServletRequest req, String key) static Persistent
getObject
(JSONObject obj) static <T extends Persistent>
List<T>getObjectList
(HttpServletRequest req, String key) Get list of objects (from multiple selection list) stored in request under keygetObjectListForComponent
(List<? extends Persistent> l) static List<Persistent>
getObjects
(Class<Persistent> c, Map<String, String> params, boolean isTable) static <T extends Persistent>
TSame as getObject, but checks view right on the object.read the parameters from node and from requeststatic String
static String
static String
getRunningSteps
(ProcessInstance pi, String delim, boolean includeLongRunning) Returns a string containing the active step of the given process with agents and step-namegetSearchCondition
(Persistent o, String searchAttrs, String searchString) builds a condition for querying the givenPersistent
uses the global setting for smartSearchgetSearchCondition
(Persistent o, String searchAttrs, String searchString, boolean smartSearch) builds a condition querying the givenPersistent
if smartSearch istrue
, the given searchString will be splitted, and searched in each searchAttr on it's ownstatic Collection<Pair<String,
String>> getSelectList2
(Map<String, String> params) static Collection<Pair<String,
String>> getSelectObjectById
(long oid, Map<String, String> params) static String
getSortAttrForSQL
(String orderAttr) static String
static TableModel
getWorklist
(HttpServletRequest req, String id) Return a worklist as table model.static void
insertSubTable
(Element el, DMSForm mainform, short mode) Insert a subform table in an XHTMLPage.static void
insertSubTable
(Element el, DMSForm mainform, short mode, ActivityInstance ai) Insert a subform table in an XHTMLPage.void
pdf
(HttpServletRequest req, HttpServletResponse res) static Page
roleList
(HttpServletRequest request) Deprecated, for removal: This API element is subject to removal in a future version.The method is used in selectUserOrRolestatic Page
Show a list of objects for selection, best for use in a popup.static Page
Show a list of objects for selection, best for use in a popup.static Page
Deprecated, for removal: This API element is subject to removal in a future version.same as selectList.static Page
Deprecated, for removal: This API element is subject to removal in a future version.use ep/widget/smartclient/form/ObjectInputField}static Page
showEmptyForm
(DMSForm f, String buttons, HttpServletRequest req) Deprecated.static Page
Show a form.static Page
Show a process form.static Page
showForm
(HttpServletRequest r, ActivityInstance ai, String formid, int mode) Show a process form.static Page
showForm
(HttpServletRequest r, ActivityInstance ai, String formid, int mode, String buttons) Deprecated.Show a Form table in its own window or iframe.static void
showPdfForm
(DMSForm form, FormContext ctx, OutputStream os, String addr, Locale l) Create a pdf out of the form.void
showPdfForm
(HttpServletRequest req, HttpServletResponse res) This methods creates a pdf from a form.Shows a window with an iframe and a close button below.This method returns a page containing a print version of a form.static Page
Show the process details, designed for opened in a popup window.static Link
showSubformLink
(Persistent obj, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction, String page) static Link
showSubformLink
(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler) static Link
showSubformLink
(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions) static Link
showSubformLink
(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction) static Link
showSubformLink
(HttpServletRequest req, String title, String subformid, int width, int height, String tablehandler, String actions, String defaultAction, String page) static void
showWorklist
(HttpServletRequest r, HttpServletResponse res, Application appl, int type, String worklist, String functions) Deprecated.static String
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>static JSONObject
toJSON
(Persistent obj) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.The method is used in selectUserOrRole
-
Field Details
-
PDF_UNSAFE_URL
- See Also:
-
SEARCH_TERM_SPLIT_PATTERN
-
FORMAT_FIELDS_AS_COMPONENT
- See Also:
-
-
Constructor Details
-
HTMLUtils
public HTMLUtils()
-
-
Method Details
-
selectList
Show a list of objects for selection, best for use in a popup.- Throws:
Exception
-
selectList2
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
-
getSortAttrForSQL
-
getSelectList2
public static Collection<Pair<String,String>> getSelectList2(Map<String, String> params) throws Exception- Throws:
Exception
-
getParameters
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
-
getStandardSearchIdOfClass
-
getSearchCondition
public static Pair<String,List<Object>> getSearchCondition(Persistent o, String searchAttrs, String searchString) builds a condition for querying the givenPersistent
uses the global setting for smartSearch- Parameters:
o
-searchAttrs
- the attrs, comma separatedsearchString
- 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 givenPersistent
if smartSearch istrue
, the given searchString will be splitted, and searched in each searchAttr on it's own- Parameters:
o
-searchAttrs
-searchString
-smartSearch
- use smartSearch?- Returns:
-
getWorklist
Return a worklist as table model.- Parameters:
req
- the HTTP requestid
- the id of the worklist, for example standard.wl- Returns:
- the worklist as table model
-
getRunningSteps
Returns a string containing the active step of the given process with agents and step-name- Parameters:
pi
- a process instancedelim
- 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
Show a process form.- Parameters:
req
- parameters: ai: the oid of an activity instance; formid: id of the form (from process defintion); mode (optional): 0 = update(default), 3: view; comingFrom: a destination url for 'back' and 'save and back' button; _viewtype (optional): value "toolbar:" will set the buttons to invisible- Throws:
Exception
-
showForm
public static Page showForm(HttpServletRequest r, ActivityInstance ai, String formid, int mode) throws Exception Show a process form.- Parameters:
r
- the requestai
- the current activityformid
- the id of the form in the process definitionmode
- 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 objectbuttons
- 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
- Throws:
Exception
-
showPrintForm
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
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 formres
- 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 objectctx
- the form context (may define visibilities)os
- on this stream the pdf is writtenaddr
- base address if the html contains links to external resources, for example imagesl
- 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 Pageos
- on this stream the pdf is writtenaddr
- base address if the html contains links to external resources, for example imagesl
- the locale used for internationalization- Throws:
Exception
-
pdf
- Throws:
Exception
-
showProcessDetails
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
-
taskProps
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
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
Same as getObject, but checks view right on the object. -
getObject
-
getDocumentsLink
- Returns:
- a link to the document folder
-
getNotesLink
- 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
-
showSubformLink
-
showSubformLink
-
showSubformLink
-
insertSubTable
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 formmode
- 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 formmode
- the mode for showing the table, RemoteWfEngine.INVISIBLE, READ_ONLY, READ_WRITE, NO_ADDDELai
- context activity instance, may be used in subtables table event handler- Throws:
Exception
-
getObjectList
Get list of objects (from multiple selection list) stored in request under key- Parameters:
req
-key
-
-
getObjectListForComponent
-
getDisplayValue
returns the given field's display value this can be:- for dates: can be either a
CalUtil.showDate(Object)
or theCalUtil.showDateTime(Object)
representation of the value - for selectlist-values: the localized display-value of the selectlist-option
- for decimal fields: the formatted value using
Settings.getDecimalFormatter()
with the max. fraction and integer digits set as defined for the field
- Parameters:
form
- the formfield
- the field, the text will be returned- Returns:
- the fields display value or
null
if no text was found
- for dates: can be either a
-
showFormTable
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
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 requestres
- the HTTP responseappl
- the applicationtype
- the type: 0..user, 1..role, 2..suspension listworklist
- a worklist implementation (implements com.groiss.wf.html.Worklist)functions
- a space-separated list of function ids- Throws:
Exception
-
toJSON
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, usegetDocumentsLink(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
-
getPrintTheme
-