Package org.compiere.util
Class WebUtil
java.lang.Object
org.compiere.util.WebUtil
Servlet Utilities
- Version:
- $Id: WebUtil.java,v 1.7 2006/09/24 12:11:54 comdivision Exp $
- Author:
- Jorg Janke
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCookieWebUser
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String webUser, String COOKIE_NAME) Deprecated.static org.apache.ecs.xhtml.option[]
convertToOption
(NamePair[] list, String default_ID) Convert Array of NamePair to HTTP Option Array.static org.apache.ecs.xhtml.input
Deprecated.static org.apache.ecs.xhtml.tr
createField
(org.apache.ecs.xhtml.tr line, String FORMNAME, String PARAMETER, String labelText, String inputType, Object value, int sizeDisplay, int size, boolean longField, boolean mandatory, String onChange, StringBuffer script) Deprecated.static void
createForwardPage
(javax.servlet.http.HttpServletResponse response, String title, String forwardURL, int delaySec) Deprecated.static void
createLoginPage
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties ctx, String AD_Message) Deprecated.static void
createResponse
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties cookieProperties, WebDoc doc, boolean debug) Create Standard Response Header with optional Cookie and print document.static void
deleteCookieWebUser
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String COOKIE_NAME) Deprecated.static boolean
Does Test existstatic boolean
Does Parameter existstatic org.apache.ecs.xhtml.script
getClearFrame
(String targetFrame) Deprecated.static Properties
getCookieProprties
(javax.servlet.http.HttpServletRequest request) Deprecated.static HtmlCode
getForward
(String url, int delaySec) Deprecated.static String
getFrom
(javax.servlet.http.HttpServletRequest request) Get Remote From infostatic String
Get server ipstatic org.apache.ecs.xhtml.input
getLoginButton
(Properties ctx) Deprecated.static String
getParameter
(javax.servlet.http.HttpServletRequest request, String parameter) Get String Parameter.static BigDecimal
getParameterAsBD
(javax.servlet.http.HttpServletRequest request, String parameter) Get numeric Parameter - 0 if not definedstatic boolean
getParameterAsBoolean
(javax.servlet.http.HttpServletRequest request, String parameter) Get boolean Parameter.static boolean
getParameterAsBoolean
(javax.servlet.http.HttpServletRequest request, String parameter, String expected) Get boolean Parameter.static Timestamp
getParameterAsDate
(javax.servlet.http.HttpServletRequest request, String parameter) Get date Parameter - null if not defined.static Timestamp
getParameterAsDate
(javax.servlet.http.HttpServletRequest request, String parameter, Language language) Get date Parameter - null if not defined.static int
getParameterAsInt
(javax.servlet.http.HttpServletRequest request, String parameter) Get integer Parameter - 0 if not defined.static String
getParamOrNull
(javax.servlet.http.HttpServletRequest request, String parameter) Get Parameter or Null if emptystatic String
Get server namestatic boolean
isEmailValid
(String email) Is EMail address validstatic boolean
returns true if the URL exists and answer with a 200 codestatic Properties
propertiesDecode
(String data) Decode data String (URL encoded) into Propertiesstatic String
Decode Properties into String (URL encoded)static String
streamAttachment
(javax.servlet.http.HttpServletResponse response, MAttachment attachment, int attachmentIndex) Stream Attachment Entrystatic String
streamFile
(javax.servlet.http.HttpServletResponse response, File file) Stream Filestatic boolean
updateFields
(javax.servlet.http.HttpServletRequest request, WebUser wu, boolean updateEMailPwd) Deprecated.
-
Constructor Details
-
WebUtil
public WebUtil()
-
-
Method Details
-
createLoginPage
@Deprecated public static void createLoginPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties ctx, String AD_Message) throws javax.servlet.ServletException, IOException Deprecated.Create Exit Page "Log-off".- End Session - Go to start page (e.g. /adempiere/index.html)
- Parameters:
request
- requestresponse
- responseservlet
- servletctx
- contextAD_Message
- messahe- Throws:
javax.servlet.ServletException
IOException
-
getLoginButton
Deprecated.Create Login Button - replace Window- Parameters:
ctx
- context- Returns:
- Button
-
getCookieProprties
@Deprecated public static Properties getCookieProprties(javax.servlet.http.HttpServletRequest request) Deprecated.Get Cookie Properties- Parameters:
request
- request- Returns:
- Properties
-
getParameter
Get String Parameter.- Parameters:
request
- requestparameter
- parameter- Returns:
- string or null
-
getParameterAsInt
public static int getParameterAsInt(javax.servlet.http.HttpServletRequest request, String parameter) Get integer Parameter - 0 if not defined.- Parameters:
request
- requestparameter
- parameter- Returns:
- int result or 0
-
getParameterAsBD
public static BigDecimal getParameterAsBD(javax.servlet.http.HttpServletRequest request, String parameter) Get numeric Parameter - 0 if not defined- Parameters:
request
- requestparameter
- parameter- Returns:
- big decimal result or 0
-
getParameterAsDate
public static Timestamp getParameterAsDate(javax.servlet.http.HttpServletRequest request, String parameter) Get date Parameter - null if not defined. Date portion only- Parameters:
request
- requestparameter
- parameter- Returns:
- timestamp result or null
-
getParameterAsDate
public static Timestamp getParameterAsDate(javax.servlet.http.HttpServletRequest request, String parameter, Language language) Get date Parameter - null if not defined. Date portion only- Parameters:
request
- requestparameter
- parameterlanguage
- optional language- Returns:
- timestamp result or null
-
getParameterAsBoolean
public static boolean getParameterAsBoolean(javax.servlet.http.HttpServletRequest request, String parameter) Get boolean Parameter.- Parameters:
request
- requestparameter
- parameter- Returns:
- true if found
-
getParameterAsBoolean
public static boolean getParameterAsBoolean(javax.servlet.http.HttpServletRequest request, String parameter, String expected) Get boolean Parameter.- Parameters:
request
- requestparameter
- parameterexpected
- optional expected value- Returns:
- true if found and if optional value matches
-
getParamOrNull
public static String getParamOrNull(javax.servlet.http.HttpServletRequest request, String parameter) Get Parameter or Null if empty- Parameters:
request
- requestparameter
- parameter- Returns:
- Request Value or null
-
createResponse
public static void createResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties cookieProperties, WebDoc doc, boolean debug) throws IOException Create Standard Response Header with optional Cookie and print document. D:\j2sdk1.4.0\docs\guide\intl\encoding.doc.html- Parameters:
request
- requestresponse
- responseservlet
- servletcookieProperties
- cookie propertiesdoc
- docdebug
- debug- Throws:
IOException
-
getClearFrame
Deprecated.Create Java Script to clear Target frame- Parameters:
targetFrame
- target frame- Returns:
- Clear Frame Script
-
getForward
Deprecated.Return a link and script with new location.- Parameters:
url
- forward urldelaySec
- delay in seconds (default 3)- Returns:
- html
-
createForwardPage
@Deprecated public static void createForwardPage(javax.servlet.http.HttpServletResponse response, String title, String forwardURL, int delaySec) throws javax.servlet.ServletException, IOException Deprecated.Create Forward Page- Parameters:
response
- responsetitle
- page titleforwardURL
- urldelaySec
- delay in seconds (default 3)- Throws:
javax.servlet.ServletException
IOException
-
exists
Does Test exist- Parameters:
test
- string- Returns:
- true if String with data
-
exists
Does Parameter exist- Parameters:
request
- requestparameter
- string- Returns:
- true if String with data
-
isEmailValid
Is EMail address valid- Parameters:
email
- mail address- Returns:
- true if valid
-
propertiesEncode
Decode Properties into String (URL encoded)- Parameters:
pp
- properties- Returns:
- Encoded String
-
propertiesDecode
Decode data String (URL encoded) into Properties- Parameters:
data
- data- Returns:
- Properties
-
convertToOption
Convert Array of NamePair to HTTP Option Array.If the ArrayList does not contain NamePairs, the String value is used
- Parameters:
list
- ArrayList containing NamePair valuesdefault_ID
- Sets the default if the key/ID value is found. If the value is null or empty, the first value is selected- Returns:
- Option Array
- See Also:
-
createField
@Deprecated public static org.apache.ecs.xhtml.tr createField(org.apache.ecs.xhtml.tr line, String FORMNAME, String PARAMETER, String labelText, String inputType, Object value, int sizeDisplay, int size, boolean longField, boolean mandatory, String onChange, StringBuffer script) Deprecated.Create label/field table row- Parameters:
line
- - null for new line (table row)FORMNAME
- form namePARAMETER
- parameter namelabelText
- labelinputType
- HTML input typevalue
- data valuesizeDisplay
- display sizesize
- data sizelongField
- field spanning two columnsmandatory
- mark as mandatoryonChange
- onChange callscript
- script- Returns:
- tr table row
-
createClosePopupButton
Deprecated.Get Close PopUp Buton- Returns:
- button
-
streamAttachment
public static String streamAttachment(javax.servlet.http.HttpServletResponse response, MAttachment attachment, int attachmentIndex) Stream Attachment Entry- Parameters:
response
- responseattachment
- attachmentattachmentIndex
- logical index- Returns:
- error message or null
-
streamFile
Stream File- Parameters:
response
- responsefile
- file to stream- Returns:
- error message or null
-
deleteCookieWebUser
@Deprecated public static void deleteCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String COOKIE_NAME) Deprecated.Remove Cookie with web user by setting user to _- Parameters:
request
- request (for context path)response
- response to add cookie
-
getFrom
Get Remote From info- Parameters:
request
- request- Returns:
- remore info
-
addCookieWebUser
@Deprecated public static void addCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String webUser, String COOKIE_NAME) Deprecated.Add Cookie with web user- Parameters:
request
- request (for context path)response
- response to add cookiewebUser
- email address
-
updateFields
@Deprecated public static boolean updateFields(javax.servlet.http.HttpServletRequest request, WebUser wu, boolean updateEMailPwd) Deprecated.Update Web User- Parameters:
request
- requestwu
- userupdateEMailPwd
- if true, change email/password- Returns:
- true if saved
-
getServerName
Get server name- Returns:
- Server name including host name: IP : instance name
-
getHostIP
Get server ip- Returns:
- server ip
-
isUrlOk
returns true if the URL exists and answer with a 200 code- Parameters:
urlString
-- Returns:
- boolean
-