jet.web.dhtml
Class DHTMLUtil

java.lang.Object
  extended by jet.web.dhtml.DHTMLUtil

public class DHTMLUtil
extends java.lang.Object

This is a utility class which can be directly invoked in JSPs.

Support the running of multiple report sets in one session, and a report set can include one or more reports.

Descriptions of some key terms:

sessionId: the key for the session in the server (generated by the server automatically when you log in), and users can invoke DHTMLUtil.getSessionID(HttpServletRequest request) to get the key.

rptSetId: the key for a report set in DHTML (generated automatically after the report set has been run), and users can invoke DHTMLUtil.getRptSetId(HttpServletRequest request) to get the key.

rptName: the key for a report in DHTML (retrieved from the report set after the report set has been run), and users can invoke DHTMLUtil.getRptName(HttpServletRequest request) to get the key.


Field Summary
static boolean BuildInVersion
           
static java.lang.String ReportNameIfCannotGet
           
 
Constructor Summary
DHTMLUtil()
           
 
Method Summary
static VersionRecord addResource(java.lang.String userId, java.lang.String folderPath, byte nodetype, java.lang.String catalogname, java.lang.String nodename, java.lang.String versionPath, boolean enableLinkCatalogMode, boolean isLinkCatalogMode, java.lang.String decs)
          Adds a resource in the specified folder.
static VersionRecord addResultInReport(java.lang.String userId, java.lang.String rptName, java.util.Hashtable htRst, java.lang.String sessionId, java.lang.String rptSetId)
          Adds a result in an existing report.
static VersionRecord addResultInReport(java.lang.String userId, java.lang.String rptName, java.lang.String rstName, java.lang.String versionPath, java.lang.String sessionId, java.lang.String rptSetId, java.lang.String rptId)
          Adds a result in an existing report.
static java.lang.String buildRuntimeID(java.lang.String SessionID, java.lang.String RptSetId, java.lang.String RptName)
          Builds runtimeID for backwards compatibility.
static java.lang.String convertArrayToJSArray(java.lang.String[] array)
          Gets the Script string of the specified array.
static java.lang.String convertArrayToJSArray(java.lang.String[][] array)
          Gets the Script string of the specified two-dimensional array.
static java.lang.String decode(java.lang.String str)
          Decodes an ecmascript format string.
static java.lang.String escape(java.lang.String str)
          Translates a string using the ecmascript format.
static java.lang.String generateJsMsg()
          Gets all the error messages in a string array which can be used in HTML page.
static java.lang.Throwable[] getAllDHTMLExceptions(HttpServletRequest request)
          Gets all exceptions.
static java.util.ArrayList getAllReports(java.lang.String userName, java.lang.String rootpath)
          Gets all reports (including sub folders, sub sub folders, ...) in the specified resource node.
static int getBrowserType(HttpServletRequest request)
          Gets the browser type.
static java.lang.String getCatalogName(java.lang.String userName, java.lang.String resourcePath)
          Gets the real path of the catalog.
static java.lang.String getDefaultToolbarItems(DHTMLConfig dhtmlConfig, java.lang.String SessionID, java.lang.String RptSetId)
          Gets the default toolbar items for the specified report set, which can be used into JavaScript.
static boolean getDirWritePermission(java.lang.String userName, java.lang.String rootpath)
          Gets whether the user has the permission of saving reports to the specified folder.
static java.lang.String getErrorMsg(int checkCode, java.lang.String language)
          Gets the error message according to the specified check code.
static jet.JException getOriginalJException(jet.JException jrex)
          Gets the cause of this exception
static double getPageHeight(int pageType, int orientation)
          Gets the page height.
static double getPageWidth(int pageType, int orientation)
          Gets the page width.
static java.lang.String getReportRealPath(java.lang.String userId, java.lang.String fileName)
          Deprecated. ResourceKit.getReportRealPath. Gets the real path and name of the report set.
static jet.server.intf.jrs.ExResourceManager getResourceManager()
          Gets the server resource manager.
static java.lang.String getRptName(HttpServletRequest request)
          Gets the report name from the request.
static java.lang.String getRptSetId(HttpServletRequest request)
          Gets the report set id from the request.
static java.lang.String getSessionID(HttpServletRequest request)
          Gets the session id from the request.
static java.lang.String getUserName(HttpServletRequest request)
          Gets the current session user name.
static UserSession getUserSession(HttpServletRequest request)
          Gets a UserSession instance from the request.
static java.lang.String getWebAppUrl(HttpServletRequest request, java.lang.String webAppName)
          Gets web application URL.
static java.lang.String getWebContextPath(java.lang.String dhtmlCtxPath)
          Gets the DHTML context path (not including "/").
static java.util.ArrayList[] IdentifyDirArrayList(java.lang.String userName, java.lang.String rootpath)
          Gets the sorted folders of the specified resource.
static boolean isChrome(HttpServletRequest request)
          Gets whether the browser is chrome.
static boolean isResourceNode(java.lang.String userName, java.lang.String path)
          Whether the specified path is resource node.
static boolean isRMIEnv(HttpServlet servlet)
          Gets whether the environment is RMI.
static java.lang.String msg(int key)
          Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.
static java.lang.String msg(int key, java.lang.Object arg)
          Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.
static java.lang.String msg(int key, java.lang.Object[] args)
          Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.
static java.lang.String replaceAllString(java.lang.String src, java.lang.String patten, java.lang.String replacement)
          Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.
static java.util.Map runReport(HttpServletRequest request, java.util.Map runParams)
          Runs a report set.
static java.lang.String scriptBegin(boolean isNoFrame_ConnectPage)
          Gets the script start string.
static java.lang.String scriptEnd(boolean isNoFrame_ConnectPage)
          Gets the script end string.
static java.lang.String[][] sortArray(java.lang.String[][] array, int sortType)
          Sorts a two-dimensional string array according to the specified sort order.
static java.lang.String[] sortArray(java.lang.String[] array, int sortType)
          Sorts a string array according to the specified sort order.
static java.lang.String toHtmlString(java.lang.String src)
          Gets the HTML string of the specified string.
Such as '\"' to """, '<' to "<".
static java.lang.String toHtmlString(java.lang.String src, boolean noSingleQuotes)
          Gets the HTML string of the specified string.
Such as '\"' to """, '<' to "<".
static java.lang.String toJSON(java.util.Hashtable ht)
          Gets the Script string of the specified parameters.
static java.lang.String toJSON(java.lang.String[] array)
          Gets the Script string of the specified parameters.
static java.lang.String toScriptString(java.lang.String oriStr)
          Gets the Script string of the specified string.
Such as '\'' to "\\\\'", "'" to "\\\\'".
static java.lang.String unescape(java.lang.String str)
           
static java.lang.String writeToolBarBtnHTML(java.lang.String[] item, java.lang.String strEvent)
          Gets the HTML string of the button in the toolbar.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BuildInVersion

public static boolean BuildInVersion

ReportNameIfCannotGet

public static java.lang.String ReportNameIfCannotGet
Constructor Detail

DHTMLUtil

public DHTMLUtil()
Method Detail

buildRuntimeID

public static java.lang.String buildRuntimeID(java.lang.String SessionID,
                                              java.lang.String RptSetId,
                                              java.lang.String RptName)
Builds runtimeID for backwards compatibility.

Parameters:
sessionId - the user session id.
rptSetId - the report set id.
rptName - the report name.
Returns:
the runtime id.

getErrorMsg

public static java.lang.String getErrorMsg(int checkCode,
                                           java.lang.String language)
Gets the error message according to the specified check code.

Parameters:
checkCode - the key of the information code generated after the report set has been run.
Defined checkCode in DHTMLConstant:
DHTMLConstant.CHECK_WRONG_CATALOG;
DHTMLConstant.CHECK_EXCEED_USER;
DHTMLConstant.CHECK_EXCEED_REPORT_SESSION;
DHTMLConstant.CHECK_EXCEED_REPORT_LICENSE;
DHTMLConstant.CHECK_EXTRA_CHANNEL;
DHTMLConstant.CHECK_OVER_MAXOPEN.
language - the language.
Returns:
the error message; null means the checkCode is undefined.

getReportRealPath

public static java.lang.String getReportRealPath(java.lang.String userId,
                                                 java.lang.String fileName)
Deprecated. ResourceKit.getReportRealPath. Gets the real path and name of the report set.

Parameters:
userId - the user name.
fileName - the relative path and name of the report set.
Returns:
the real path and name of the report set.

getRptSetId

public static java.lang.String getRptSetId(HttpServletRequest request)
Gets the report set id from the request.

Parameters:
request - HttpServletRequest.
Returns:
the report set id.

getRptName

public static java.lang.String getRptName(HttpServletRequest request)
Gets the report name from the request.

Parameters:
request - HttpServletRequest.
Returns:
the report name.

getSessionID

public static java.lang.String getSessionID(HttpServletRequest request)
Gets the session id from the request.

Parameters:
request - HttpServletRequest.
Returns:
String the session id.

getUserSession

public static UserSession getUserSession(HttpServletRequest request)
Gets a UserSession instance from the request.

Parameters:
request - HttpServletRequest.
Returns:
UserSession.
See Also:
jet.server.api.UserSession.

runReport

public static java.util.Map runReport(HttpServletRequest request,
                                      java.util.Map runParams)
                               throws jet.JDException
Runs a report set.

Parameters:
request - HttpServletRequest.
runParams - the additional information for running the report set.
Returns:
the information about a report set.
Throws:
jet.JDException
See Also:
jet.web.dhtml.WebActLogic.runReport.

isChrome

public static boolean isChrome(HttpServletRequest request)
Gets whether the browser is chrome.

Parameters:
request - HttpServletRequest.
Returns:
true means the browser is chrome; otherwise, not chrome.

getBrowserType

public static int getBrowserType(HttpServletRequest request)
Gets the browser type.

Parameters:
request - HttpServletRequest.
Returns:
the browser type which is defined in DHTMLConstant:
DHTMLConstant.BROWSER_OPERA;
DHTMLConstant.BROWSER_CHROME;
DHTMLConstant.BROWSER_NETSCAPE;
DHTMLConstant.BROWSER_FIREFOX;
DHTMLConstant.BROWSER_IE;
DHTMLConstant.BROWSER_MOZILLA.

isRMIEnv

public static boolean isRMIEnv(HttpServlet servlet)
Gets whether the environment is RMI.

Parameters:
servlet - HttpServlet.
Returns:
true means RMI environment; otherwise not RMI.

sortArray

public static java.lang.String[] sortArray(java.lang.String[] array,
                                           int sortType)
Sorts a string array according to the specified sort order.

Parameters:
array - a string array.
sortType - the sort order type which is defined in DHTMLConstant:
DHTMLConstant.SORT_ASCENDING;
DHTMLConstant.SORT_DESCENDING.
Returns:
the sorted string array.

sortArray

public static java.lang.String[][] sortArray(java.lang.String[][] array,
                                             int sortType)
Sorts a two-dimensional string array according to the specified sort order.

Parameters:
array - a two-dimensional string array.
sortType - the sort order type which is defined in DHTMLConstant:
DHTMLConstant.SORT_ASCENDING;
DHTMLConstant.SORT_DESCENDING.
Returns:
the sorted two-dimensional string array.

getWebAppUrl

public static java.lang.String getWebAppUrl(HttpServletRequest request,
                                            java.lang.String webAppName)
Gets web application URL.

Parameters:
request - HttpServletRequest.
webAppName - the web application name.
Returns:
the web application URL.
See Also:
jet.server.api.http.HttpUtil.getWebAppUrl.

scriptBegin

public static java.lang.String scriptBegin(boolean isNoFrame_ConnectPage)
Gets the script start string.

An example of the method:

%serverhome%/public_html/dhtmljsp/index.jsp.

Parameters:
isNoFrame_ConnectPage - whether the current page is the connecting page.
Returns:
the script start string.

scriptEnd

public static java.lang.String scriptEnd(boolean isNoFrame_ConnectPage)
Gets the script end string.

An example of the method:

%serverhome%/public_html/dhtmljsp/index.jsp.

Parameters:
isNoFrame_ConnectPage - whether the current page is the connecting page.
Returns:
the script end string.

getPageWidth

public static double getPageWidth(int pageType,
                                  int orientation)
Gets the page width.

An example of the method:

%serverhome%/public_html/dhtmljsp/dialog/pageproperty.jsp.

Parameters:
pageType - the page type.
orientation - the page orientation:
0 is landscape;
1 is portrait.
Returns:
the page width in inches.

getPageHeight

public static double getPageHeight(int pageType,
                                   int orientation)
Gets the page height.

An example of the method:

%serverhome%/public_html/dhtmljsp/dialog/pageproperty.jsp.

Parameters:
pageType - the page type.
orientation - the page orientation:
0 is landscape;
1 is portrait.
Returns:
the page height in inches.

getResourceManager

public static jet.server.intf.jrs.ExResourceManager getResourceManager()
Gets the server resource manager.

An example of the method:

%serverhome%/public_html/dhtmljsp/save_as.jsp.

Returns:
@see jet.server.intf.jrs.ExResourceManager.

isResourceNode

public static boolean isResourceNode(java.lang.String userName,
                                     java.lang.String path)
Whether the specified path is resource node.

An example of the method:

%serverhome%/public_html/dhtmljsp/index.jsp.

Parameters:
userName - the user name.
path - the resource path.
Returns:
whether the specified path is resource node.

addResource

public static VersionRecord addResource(java.lang.String userId,
                                        java.lang.String folderPath,
                                        byte nodetype,
                                        java.lang.String catalogname,
                                        java.lang.String nodename,
                                        java.lang.String versionPath,
                                        boolean enableLinkCatalogMode,
                                        boolean isLinkCatalogMode,
                                        java.lang.String decs)
                                 throws NoPrivilegeException,
                                        NodeExistsException,
                                        UnknownResource
Adds a resource in the specified folder.

Parameters:
userId - the user name.
folderPath - the folder resource path.
nodetype - the node type.
catalogname - the catalog name.
nodename - the node name.
versionPath - the version path.
enableLinkCatalogMode - whether to enable linked catalog.
isLinkCatalogMode - whether it is linked catalog.
desc - the description.
Returns:
@see jet.server.api.VersionRecord.
Throws:
UnknownResource
NodeExistsException
NoPrivilegeException

addResultInReport

public static VersionRecord addResultInReport(java.lang.String userId,
                                              java.lang.String rptName,
                                              java.lang.String rstName,
                                              java.lang.String versionPath,
                                              java.lang.String sessionId,
                                              java.lang.String rptSetId,
                                              java.lang.String rptId)
                                       throws NoPrivilegeException,
                                              UnknownResource
Adds a result in an existing report.

Parameters:
userId - the user name.
rptName - the logical path of the report.
rstName - the result node name.
resultPath - the real path of result file.
sessionId - the user session id.
rptSetId - the report set id.
rptId - the report id.
Returns:
@see jet.server.api.VersionRecord.
Throws:
NoPrivilegeException
UnknownResource

addResultInReport

public static VersionRecord addResultInReport(java.lang.String userId,
                                              java.lang.String rptName,
                                              java.util.Hashtable htRst,
                                              java.lang.String sessionId,
                                              java.lang.String rptSetId)
                                       throws UnknownResource,
                                              NoPrivilegeException
Adds a result in an existing report.

Parameters:
userId - the user name.
rptName - the logical path of the report.
htRst - the necessary parameters.
sessionId - the user session id.
rptSetId - the report set id.
Returns:
@see jet.server.api.VersionRecord.
Throws:
UnknownResource
NoPrivilegeException

IdentifyDirArrayList

public static java.util.ArrayList[] IdentifyDirArrayList(java.lang.String userName,
                                                         java.lang.String rootpath)
                                                  throws jet.JDException
Gets the sorted folders of the specified resource.

An example of the method:

%serverhome%/public_html/dhtmljsp/save_as.jsp.

Parameters:
userName - the user name.
rootpath - the resource path.
Returns:
the sorted folders.
Throws:
jet.JDException

getDirWritePermission

public static boolean getDirWritePermission(java.lang.String userName,
                                            java.lang.String rootpath)
                                     throws jet.JDException
Gets whether the user has the permission of saving reports to the specified folder.

An example of the method:

%serverhome%/public_html/dhtmljsp/save_as.jsp.

Parameters:
userName - the user name.
rootpath - the resource path.
Returns:
whether the user has the permission.
Throws:
jet.JDException

getAllReports

public static java.util.ArrayList getAllReports(java.lang.String userName,
                                                java.lang.String rootpath)
                                         throws jet.JDException
Gets all reports (including sub folders, sub sub folders, ...) in the specified resource node.

An example of the method:

%serverhome%/public_html/dhtmljsp/save_as.jsp.

Parameters:
userName - the user name.
rootpath - the resource path.
Returns:
all reports in the specified resource node.
Throws:
jet.JDException

toHtmlString

public static java.lang.String toHtmlString(java.lang.String src)
Gets the HTML string of the specified string.
Such as '\"' to """, '<' to "<".

Parameters:
src - the original string.
Returns:
the HTML string.

toHtmlString

public static java.lang.String toHtmlString(java.lang.String src,
                                            boolean noSingleQuotes)
Gets the HTML string of the specified string.
Such as '\"' to """, '<' to "<".

An example of the method:

%serverhome%/public_html/dhtmljsp/selectvalues.jsp.

Parameters:
src - the original string.
noSingleQuotes - whether to convert the single quote. If false, '\'' will be "'", otherwise, no change.
Returns:
the HTML string.

toScriptString

public static java.lang.String toScriptString(java.lang.String oriStr)
Gets the Script string of the specified string.
Such as '\'' to "\\\\'", "'" to "\\\\'".

An example of the method:

%serverhome%/public_html/dhtmljsp/run_report.jsp.

Parameters:
oriStr - the original string.
Returns:
the Script string.

writeToolBarBtnHTML

public static java.lang.String writeToolBarBtnHTML(java.lang.String[] item,
                                                   java.lang.String strEvent)
Gets the HTML string of the button in the toolbar.

An example of the method:

%serverhome%/public_html/dhtmljsp/tool_button.jsp.

Parameters:
item - the button item information:
[0] the button id which is defined in DHTMLConstant.SIMPLE_VIEW_TOOLBAR or DHTMLConstant.PAGE_CONTROL_TOOLBAR.
[1] if true, strEvent is not used; otherwise, used.
[2] if true, when mouse over the button there is no change; otherwise, change the button style when mouse over or out.
strEvent - the button event string, such as "onclick=clickAct();".
Returns:
the HTML string of the button in the toolbar.

getUserName

public static java.lang.String getUserName(HttpServletRequest request)
Gets the current session user name.

An example of the method:

%serverhome%/public_html/dhtmljsp/index.jsp.

Parameters:
request - HttpServletRequest.
Returns:
the user name.

msg

public static java.lang.String msg(int key,
                                   java.lang.Object[] args)
Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.

Parameters:
key - the error id.
args - the values you replace the error message necessary parameter such as {0},{1}... 31012887=Input the value of {0} should be following the format {1}.
Returns:
the error message.

msg

public static java.lang.String msg(int key,
                                   java.lang.Object arg)
Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.

Parameters:
key - the error id.
arg - the value you replace the error message necessary parameter such as \\"{0}\\", 1000114=Page report \\"{0}\\" already exists. Create a new version of this page report?
Returns:
the error message.

msg

public static java.lang.String msg(int key)
Gets the error message according to the specified id.
It is for NLS support, the id and the message can be seen in %serverhome%/resources/server/languages/en/properties/dhtml.properties.

An example of the method:

%serverhome%/public_html/dhtmljsp/closeWindow.jsp.

Parameters:
key - the error id.
Returns:
the error message.

generateJsMsg

public static java.lang.String generateJsMsg()
Gets all the error messages in a string array which can be used in HTML page.

An example of the method:

%serverhome%/public_html/dhtmljsp/dialogjsp/dialogheader.jsp.

Returns:
all the error messages.

unescape

public static java.lang.String unescape(java.lang.String str)
See Also:

An example of the method:

%serverhome%/public_html/dhtmljsp/searchdialog.jsp.


escape

public static java.lang.String escape(java.lang.String str)
Translates a string using the ecmascript format.

An example of the method:

%serverhome%/public_html/dhtmljsp/searchdialog.jsp.

Parameters:
str - String to be translated.
Returns:
the translated String.

decode

public static java.lang.String decode(java.lang.String str)
Decodes an ecmascript format string.

An example of the method:

%serverhome%/public_html/dhtmljsp/selectvalues.jsp.

Parameters:
str - the String to decode.
Returns:
the newly decoded String.

getOriginalJException

public static jet.JException getOriginalJException(jet.JException jrex)
Gets the cause of this exception

An example of the method:

%serverhome%/public_html/dhtmljsp/errorpage.jsp.

Parameters:
jrex - the exception.
Returns:
the cause.

getAllDHTMLExceptions

public static java.lang.Throwable[] getAllDHTMLExceptions(HttpServletRequest request)
Gets all exceptions.

An example of the method:

%serverhome%/public_html/dhtmljsp/errorpage.jsp.

Parameters:
request - HttpServletRequest.
Returns:
all exceptions.

replaceAllString

public static java.lang.String replaceAllString(java.lang.String src,
                                                java.lang.String patten,
                                                java.lang.String replacement)
Replaces every subsequence of the input sequence that matches the pattern with the given replacement string.

Parameters:
src - the input sequence.
patten - the expression to be compiled.
replacement - the replacement string.
Returns:
the string constructed by replacing each matching subsequence by the replacement string.

getCatalogName

public static java.lang.String getCatalogName(java.lang.String userName,
                                              java.lang.String resourcePath)
Gets the real path of the catalog.

Parameters:
userName - the user name.
resourcePath - the relative path of the catalog resources.
Returns:
the real path of the catalog.

getWebContextPath

public static java.lang.String getWebContextPath(java.lang.String dhtmlCtxPath)
Gets the DHTML context path (not including "/").

Parameters:
dhtmlCtxPath - the original DHTML context path.
Returns:
the DHTML context path.

convertArrayToJSArray

public static java.lang.String convertArrayToJSArray(java.lang.String[] array)
Gets the Script string of the specified array.

An example of the method:

%serverhome%/public_html/dhtmljsp/change_style.jsp.

Parameters:
array - the specified string array.
Returns:
the string.

convertArrayToJSArray

public static java.lang.String convertArrayToJSArray(java.lang.String[][] array)
Gets the Script string of the specified two-dimensional array.

An example of the method:

%serverhome%/public_html/dhtmljsp/change_style.jsp.

Parameters:
array - the specified two-dimensional string array.
Returns:
the string.

getDefaultToolbarItems

public static java.lang.String getDefaultToolbarItems(DHTMLConfig dhtmlConfig,
                                                      java.lang.String SessionID,
                                                      java.lang.String RptSetId)
Gets the default toolbar items for the specified report set, which can be used into JavaScript.

An example of the method:

%serverhome%/public_html/dhtmljsp/option_customize.jsp.

Parameters:
dhtmlConfig - @see DHTMLConfig.
SessionID - the user session id.
RptSetId - the report set id.
Returns:
the default toolbar items, such as [["ToolbarsName","ItemID|ItemID|..."],...["ToolbarsName","ItemID|ItemID|..."]].
ToolbarsName is defined in DHTMLConstant:
DHTMLConstant.TOOLBAR_STANDARD_NAME;
DHTMLConstant.TOOLBAR_ANALYSIS_NAME;
DHTMLConstant.TOOLBAR_VIEW_NAME.

toJSON

public static java.lang.String toJSON(java.util.Hashtable ht)
Gets the Script string of the specified parameters.

An example of the method:

%serverhome%/public_html/dhtmljsp/index.jsp.

Parameters:
ht - the specified parameters.
Returns:
the Script string.

toJSON

public static java.lang.String toJSON(java.lang.String[] array)
Gets the Script string of the specified parameters.

Parameters:
array - the specified parameters.
Returns:
the Script string.