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.Cookie
addCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)
Adds a cookie to the response object.void
addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie to the response object.javax.servlet.http.Cookie
createCookie(java.lang.String cookieName, java.lang.String cookieValue, int age)
Creates ajavax.servlet.http.Cookie
but does NOT add the cookie to the response object.java.lang.String
getCookieValue(java.lang.String cookieName)
Returns the value of the named cookie ornull
if the cookie does not exist.FormSession
getFormSession()
Returns aFormSession
object which represents a single browser window, usually a separate tab within the clilent browser.WrappedHttpSession
getHttpSession()
Returns theHttpSession
object representing the client browser session.int
getIEVersion()
Returns the MS Internet Explorer version.javax.servlet.http.HttpServletRequest
getRequest()
Returns theHttpServletRequest
object for the user request.javax.servlet.http.HttpServletResponse
getResponse()
Returns theHttpServletResponse
object used to send a response to the user.java.lang.String
getUserAgent()
Returns theuser-agent
request header.java.lang.String
getWebappUrlBase()
Returns a base URL to access the root of the current web application i.e.boolean
isBackButtonUsed()
Returnstrue
if the user has clicked the back button immediately prior to the request currently being processed.boolean
isChrome()
Returnstrue
when the client browser is Chrome, otherwise returnsfalse
.boolean
isEdge()
Returnstrue
when the client browser is MS Edge, otherwise returnsfalse
.boolean
isFirefox()
Returnstrue
when the client browser is Firefox, otherwise returnsfalse
.boolean
isIE()
Returnstrue
when the client browser is MS Internet Explorer, otherwise returnsfalse
.boolean
isJavascriptUsed()
Returnstrue
if Javascript is currently being used.boolean
isMobile()
Returnstrue
when the client browser is a mobile phone.boolean
isOpera()
Returnstrue
when the client browser is Opera, otherwise returnsfalse
.boolean
isSafari()
Returnstrue
when the client browser is Safari, otherwise returnsfalse
.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
supportsCookies()
Returnsfalse
if cookies are disabled on the client browser, otherwise returnstrue
.boolean
supportsJavascript()
Returnsfalse
if Javascript is disabled on the client browser, otherwise returnstrue
.
-
Method Details
-
getRequest
javax.servlet.http.HttpServletRequest getRequest()Returns theHttpServletRequest
object 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 theHttpSession
object 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 theHttpServletResponse
object 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 ornull
if 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. Theage
parameter 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.Cookie
but 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
age
parameter 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-agent
request header. This contains a description of the browser type.- Returns:
- user-agent request header
- Since:
- V4.4
-
supportsCookies
boolean supportsCookies()Returnsfalse
if cookies are disabled on the client browser, otherwise returnstrue
.- Since:
- V4.4
-
supportsJavascript
boolean supportsJavascript()Returnsfalse
if 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()Returnstrue
when the client browser is Firefox, otherwise returnsfalse
.- Since:
- V4.4
-
isEdge
boolean isEdge()Returnstrue
when the client browser is MS Edge, otherwise returnsfalse
.- Since:
- V5.4
-
isIE
boolean isIE()Returnstrue
when the client browser is MS Internet Explorer, otherwise returnsfalse
.- Since:
- V4.4
-
isChrome
boolean isChrome()Returnstrue
when the client browser is Chrome, otherwise returnsfalse
.- Since:
- V4.4
-
isOpera
boolean isOpera()Returnstrue
when the client browser is Opera, otherwise returnsfalse
.- Since:
- V4.4
-
isSafari
boolean isSafari()Returnstrue
when 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()Returnstrue
when the client browser is a mobile phone.- Since:
- V4.4
-
isBackButtonUsed
boolean isBackButtonUsed()Returnstrue
if 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()Returnstrue
if Javascript is currently being used. Returnsfalse
if 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 aFormSession
object 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
-