Package com.ebasetech.xi.api
Interface Client
public interface Client
The
Client interface provides information and methods pertaining to the client browser,
including access to the request and response objects, methods to create and read cookies, and information on the capabilities of
the client browser.- Since:
- V4.4
-
Method Summary
Modifier and Type Method Description javax.servlet.http.CookieaddCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)Adds a cookie to the response object.voidaddCookie(javax.servlet.http.Cookie cookie)Adds a cookie to the response object.javax.servlet.http.CookiecreateCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)Creates ajavax.servlet.http.Cookiebut does NOT add the cookie to the response object.java.lang.StringgetCookieValue(java.lang.String cookieName)Returns the value of the named cookie ornullif the cookie does not exist.FormSessiongetFormSession()Returns aFormSessionobject which represents a single browser window, usually a separate tab within the clilent browser.WrappedHttpSessiongetHttpSession()Returns theHttpSessionobject representing the client browser session.intgetIEVersion()Returns the MS Internet Explorer version.javax.servlet.http.HttpServletRequestgetRequest()Returns theHttpServletRequestobject for the user request.javax.servlet.http.HttpServletResponsegetResponse()Returns theHttpServletResponseobject used to send a response to the user.java.lang.StringgetUserAgent()Returns theuser-agentrequest header.java.lang.StringgetWebappUrlBase()Returns a base URL to access the root of the current web application i.e.booleanisBackButtonUsed()Returnstrueif the user has clicked the back button immediately prior to the request currently being processed.booleanisChrome()Returnstruewhen the client browser is Chrome, otherwise returnsfalse.booleanisEdge()Returnstruewhen the client browser is MS Edge, otherwise returnsfalse.booleanisFirefox()Returnstruewhen the client browser is Firefox, otherwise returnsfalse.booleanisIE()Returnstruewhen the client browser is MS Internet Explorer, otherwise returnsfalse.booleanisJavascriptUsed()Returnstrueif Javascript is currently being used.booleanisMobile()Returnstruewhen the client browser is a mobile phone.booleanisOpera()Returnstruewhen the client browser is Opera, otherwise returnsfalse.booleanisSafari()Returnstruewhen the client browser is Safari, otherwise returnsfalse.booleanisSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.booleansupportsCookies()Returnsfalseif cookies are disabled on the client browser, otherwise returnstrue.booleansupportsJavascript()Returnsfalseif Javascript is disabled on the client browser, otherwise returnstrue.
-
Method Details
-
getRequest
javax.servlet.http.HttpServletRequest getRequest()Returns theHttpServletRequestobject for the user request. This can be used to access information such as request parameters, request headers, user's ip address etc.- Returns:
- request object
- Since:
- V4.4
-
getHttpSession
WrappedHttpSession getHttpSession()Returns theHttpSessionobject representing the client browser session.When there is a need to get/set session attributes, consider using method getFormSession() instead of this method. This gives access to session attributes within a scope limited to just a single browser tab. This, in turn, allows the user to concurrently run the same form in multiple browser tabs without the risk that these might interfere with each other.
- Returns:
- session object
- Since:
- V4.4
- See Also:
getFormSession()
-
getResponse
javax.servlet.http.HttpServletResponse getResponse()Returns theHttpServletResponseobject used to send a response to the user.- Returns:
- response object
- Since:
- V4.4
-
getCookieValue
java.lang.String getCookieValue(java.lang.String cookieName)Returns the value of the named cookie ornullif the cookie does not exist.- Returns:
- cookie value
- Since:
- V4.4
-
addCookie
javax.servlet.http.Cookie addCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)Adds a cookie to the response object. Theageparameter specifies the lifetime of the cookie in seconds. A negative value denotes a session cookie i.e. not persisted on the client. A value of 0 deletes the cookie. NB The new cookie's value will not be available to getCookieValue() until the next request.- Parameters:
cookieName- the name of the new cookiecookieValue- the value of the new cookieage- age of the cookie in seconds, see above description- Returns:
- the added cookie
- Since:
- V4.4
-
createCookie
javax.servlet.http.Cookie createCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)Creates ajavax.servlet.http.Cookiebut does NOT add the cookie to the response object. Once the cookie has been added to the response, it is no longer possible to change the cookie. This method should be used in conjunction withaddCookie(Cookie)The
ageparameter specifies the lifetime of the cookie in seconds. A negative value denotes a session cookie i.e. not persisted on the client. A value of 0 deletes the cookie. NB The new cookie's value will not be available to getCookieValue() until the next request.Javascript example:
var newCookie = client.createCookie("FullName", "Joe Bloggs", 1000000); newCookie.setSecure(true); newCookie.setHttpOnly(true); client.addCookie(newCookie);- Parameters:
cookieName- the name of the new cookiecookieValue- the value of the new cookieage- age of the cookie in seconds, see above description- Returns:
- the created cookie
- Since:
- V5.10
- See Also:
addCookie(Cookie)
-
addCookie
void addCookie(javax.servlet.http.Cookie cookie)Adds a cookie to the response object. This method should be used in conjunction withcreateCookie(String, String, int)NB The new cookie's value will not be available to getCookieValue() until the next request.- Parameters:
cookie-- Since:
- V5.10
- See Also:
createCookie(String, String, int)
-
getUserAgent
java.lang.String getUserAgent()Returns theuser-agentrequest header. This contains a description of the browser type.- Returns:
- user-agent request header
- Since:
- V4.4
-
supportsCookies
boolean supportsCookies()Returnsfalseif cookies are disabled on the client browser, otherwise returnstrue.- Since:
- V4.4
-
supportsJavascript
boolean supportsJavascript()Returnsfalseif Javascript is disabled on the client browser, otherwise returnstrue. Note that Javascript may not be used even though this is supported by the browser, as Javascript can be disabled using system preferences. To check whether Javascript is being used, use methodisJavascriptUsed().- Since:
- V4.4
-
isFirefox
boolean isFirefox()Returnstruewhen the client browser is Firefox, otherwise returnsfalse.- Since:
- V4.4
-
isEdge
boolean isEdge()Returnstruewhen the client browser is MS Edge, otherwise returnsfalse.- Since:
- V5.4
-
isIE
boolean isIE()Returnstruewhen the client browser is MS Internet Explorer, otherwise returnsfalse.- Since:
- V4.4
-
isChrome
boolean isChrome()Returnstruewhen the client browser is Chrome, otherwise returnsfalse.- Since:
- V4.4
-
isOpera
boolean isOpera()Returnstruewhen the client browser is Opera, otherwise returnsfalse.- Since:
- V4.4
-
isSafari
boolean isSafari()Returnstruewhen the client browser is Safari, otherwise returnsfalse.- Since:
- V4.4
-
getIEVersion
int getIEVersion()Returns the MS Internet Explorer version.- Since:
- V4.4
-
isMobile
boolean isMobile()Returnstruewhen the client browser is a mobile phone.- Since:
- V4.4
-
isBackButtonUsed
boolean isBackButtonUsed()Returnstrueif the user has clicked the back button immediately prior to the request currently being processed. Note that whentrue, any back button event specified at form level will be executed.- Since:
- V4.4
-
isJavascriptUsed
boolean isJavascriptUsed()Returnstrueif Javascript is currently being used. Returnsfalseif either Javascript is disabled on the client, or Javascript is disabled on the Ebase server using system preferences.- Since:
- V4.4
- See Also:
supportsJavascript(),SystemPreferences.isUseJavascript()
-
isSecure
boolean isSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.- Since:
- V4.4
-
getFormSession
FormSession getFormSession()Returns aFormSessionobject which represents a single browser window, usually a separate tab within the clilent browser. The form session object gives access to form session attributes, which exist for the duration of the HTTP session, but are limited in scope to just a single form session - usually a browser tab.- Since:
- V4.4
- See Also:
getHttpSession()
-
getWebappUrlBase
java.lang.String getWebappUrlBase()Returns a base URL to access the root of the current web application i.e. returns a URL of the type: scheme://host:port/webapp e.g. https://mydomain.com:80/ebase- Since:
- V5.2
-