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) Add Cookie with web userstatic 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
Get Close PopUp Butonstatic 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) Create label/field table rowstatic void
createForwardPage
(javax.servlet.http.HttpServletResponse response, String title, String forwardURL, int delaySec) Create Forward Pagestatic void
createLoginPage
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServlet servlet, Properties ctx, String AD_Message) Create Exit Page "Log-off".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) Remove Cookie with web user by setting user to _static boolean
Does Test existstatic boolean
Does Parameter existstatic org.apache.ecs.xhtml.script
getClearFrame
(String targetFrame) Create Java Script to clear Target framestatic Properties
getCookieProprties
(javax.servlet.http.HttpServletRequest request) Get Cookie Propertiesstatic HtmlCode
getForward
(String url, int delaySec) Return a link and script with new location.static String
getFrom
(javax.servlet.http.HttpServletRequest request) Get Remote From infostatic String
static org.apache.ecs.xhtml.input
getLoginButton
(Properties ctx) Create Login Button - replace Windowstatic 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 fi emptystatic String
static 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) Update Web User
-
Constructor Details
-
WebUtil
public WebUtil()
-
-
Method Details
-
createLoginPage
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 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
Create Login Button - replace Window- Parameters:
ctx
- context- Returns:
- Button
-
getCookieProprties
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 fi 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
Create Java Script to clear Target frame- Parameters:
targetFrame
- target frame- Returns:
- Clear Frame Script
-
getForward
Return a link and script with new location.- Parameters:
url
- forward urldelaySec
- delay in seconds (default 3)- Returns:
- html
-
createForwardPage
public static void createForwardPage(javax.servlet.http.HttpServletResponse response, String title, String forwardURL, int delaySec) throws javax.servlet.ServletException, IOException 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
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) 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
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
public static void deleteCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String COOKIE_NAME) 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
public static void addCookieWebUser(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String webUser, String COOKIE_NAME) Add Cookie with web user- Parameters:
request
- request (for context path)response
- response to add cookiewebUser
- email address
-
updateFields
public static boolean updateFields(javax.servlet.http.HttpServletRequest request, WebUser wu, boolean updateEMailPwd) Update Web User- Parameters:
request
- requestwu
- userupdateEMailPwd
- if true, change email/password- Returns:
- true if saved
-
getServerName
- Returns:
- Servername including host name: IP : instance name
-
getHostIP
-
isUrlOk
returns true if the URL exists and answer with a 200 code- Parameters:
urlString
-- Returns:
- boolean
-