|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WEnvironment
public class WEnvironment
A class that captures information on the application environment.
The environment provides information on the client, and gives access to startup arguments.
Usage example:
WEnvironment env = WApplication.instance().environment();
// read an application startup argument
// (passed as argument in the URL or POST'ed to the application).
if (!env.getParameterValues("login").isEmpty()) {
String login = env.getParameterValues("login").get(0);
//...
}
// Check for JavaScript/AJAX availability before using JavaScript-only
// widgets
WTextArea textEdit;
if (!env.isAjax())
textEdit = new WTextEdit(); // provide an HTML text editor
else
textEdit = new WTextArea(); // fall-back to a plain old text area.
| Nested Class Summary | |
|---|---|
static class |
WEnvironment.ContentType
Enumeration for HTML content type. |
static class |
WEnvironment.UserAgent
An enumeration type for specific user agent. |
| Field Summary | |
|---|---|
protected java.lang.String |
publicDeploymentPath_
|
| Method Summary | |
|---|---|
boolean |
agentIsChrome()
Returns whether the user agent is Chrome. |
boolean |
agentIsGecko()
Returns whether the user agent is Gecko-based. |
boolean |
agentIsIE()
Returns whether the user agent is Microsoft Internet Explorer. |
boolean |
agentIsIElt(int version)
Returns whether the user agent is an older version of IE. |
boolean |
agentIsIEMobile()
Returns whether the user agent is Internet Explorer Mobile. |
boolean |
agentIsMobileWebKit()
Returns whether the user agent is Mobile WebKit-based. |
boolean |
agentIsOpera()
Returns whether the user agent is Opera. |
boolean |
agentIsSafari()
Returns whether the user agent is Safari. |
boolean |
agentIsSpiderBot()
Returns if the user agent is a (known) indexing spider bot. |
boolean |
agentIsWebKit()
Returns whether the user agent is WebKit-based. |
java.lang.String |
getAccept()
Returns the accept header. |
WEnvironment.UserAgent |
getAgent()
Returns the user agent type. |
java.lang.String |
getCgiValue(java.lang.String varName)
Returns a raw CGI environment variable. |
java.lang.String |
getClientAddress()
Returns the IP address of the client. |
WEnvironment.ContentType |
getContentType()
The type of the content provided to the browser. |
java.lang.String |
getCookie(java.lang.String cookieNname)
Returns a cookie value. |
java.util.Map<java.lang.String,java.lang.String> |
getCookies()
Returns the cookies from the environment. |
java.lang.String |
getDeploymentPath()
Returns the deployment path. |
double |
getDpiScale()
Returns the browser-side DPI scaling factor. |
java.lang.String |
getHeaderValue(java.lang.String name)
Returns a header value. |
java.lang.String |
getHostName()
Returns the server host name that is used by the client. |
java.lang.String |
getInternalPath()
Returns the initial internal path. |
static java.lang.String |
getJavaScriptWtScope()
Wt's JavaScript scope. |
static java.lang.String |
getLibraryVersion()
Returns the version of the JWt library. |
java.util.Locale |
getLocale()
Returns the preferred language indicated in the request header. |
java.lang.String |
getParameter(java.lang.String name)
Returns a single value for a query parameter. |
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap()
Parameters passed to the application. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns values for a query parameter. |
java.lang.String |
getReferer()
Returns the referer. |
WtServlet |
getServer()
Returns the servlet. |
java.lang.String |
getServerAdmin()
Returns the email address of the server admin. |
java.lang.String |
getServerSignature()
Returns the web server signature. |
java.lang.String |
getServerSoftware()
Returns the web server software. |
java.lang.String |
getSessionId()
Deprecated. Use WApplication#getSessionId() instead |
java.lang.String |
getUrlScheme()
Returns the URL scheme used for the current request ( "http" or "https"). |
java.lang.String |
getUserAgent()
Returns the user agent. |
boolean |
hasAjax()
Returns whether the browser has enabled support for AJAX. |
boolean |
hashInternalPaths()
|
boolean |
hasJavaScript()
Returns whether the browser has enabled support for JavaScript. |
boolean |
isTest()
|
boolean |
supportsCookies()
Returns whether the browser has enabled support for cookies. |
boolean |
supportsCss3Animations()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String publicDeploymentPath_
| Method Detail |
|---|
public static java.lang.String getJavaScriptWtScope()
public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
Arguments passed to the application, either in the URL for a http GET, or in both the URL and data submitted in a http POST.
getParameterValues(String name)public java.lang.String[] getParameterValues(java.lang.String name)
Returns an empty list if the parameter was not defined.
One or more values may be associated with a single argument.
For example a JWt application foo.wt started as
http://.../foo.wt?hello=Hello&hello=World
will result in both values "Hello" and
"World" to be associated with the argument
"hello".
getParameterMap()public java.lang.String getParameter(java.lang.String name)
Returns the first value for a parameter, or null if the
parameter is not found.
getParameterValues(String name)public java.util.Map<java.lang.String,java.lang.String> getCookies()
This returns all cookies that were present in initial request for the
application. Cookies set with
WApplication#setCookie() are not taken into considerations.
Cookies allow you to persist information across sessions.
Not all clients may support cookies or have cookies enabled.
supportsCookies(),
getCookie(String cookieNname),
WEnvironment#getCookieValue(String cookieName)public java.lang.String getCookie(java.lang.String cookieNname)
Throws a RuntimeException("Missing cookie: ...")
when the cookie is missing, or returns cookie value otherwise.
WEnvironment#getCookieValue(String cookieName)public java.lang.String getHeaderValue(java.lang.String name)
Returns a header value, or an empty string if the header was present.
Note: Currently, the header name is case sensitive, although this should not be the case according to RFC2616
public boolean supportsCookies()
When the user disables cookies during the visit of the page, this value is not updated.
getCookies(),
getCookie(String cookieNname)public boolean hasJavaScript()
This is the same as hasAjax(): JWt only
considers using JavaScript when it has detected AJAX support.
hasAjax()public boolean hasAjax()
Without support for JavaScript/AJAX, JWt will still be able to serve the
application, but with one considerable limitation: only the
WTimer#timeout(),
WInteractWidget#clicked(),
WApplication#internalPathChanged(), and WAbstractArea#clicked() signals (and any derived signals) will generate
events.
Every event will cause the complete page to be rerendered.
hasJavaScript()public double getDpiScale()
Internet Explorer scales all graphics, fonts and other elements on high-density screens to make them readable. This is controlled by the DPI setting of the display. If all goes well, you do not have to worry about this scaling factor. Unfortunately, not all elements are scaled appropriately. The scaling factor is supposed to be used only internally in JWt and is in this interface for informational purposes.
WVmlImagepublic java.util.Locale getLocale()
The language is parsed from the HTTP Accept-Language field,
if present. If not, the locale is empty.
If multiple languages are present, the one with the highest "q"uality is assumed, and if a tie is present, the first one is taken.
WApplication.setLocale(Locale locale)public java.lang.String getHostName()
The hostname is the unresolved host name with optional port number, which the browser used to connect to the application.
Examples:
www.mydomain.comlocalhost:8080
For HTTP 1.1 requests, this information is fetched from the HTTP
Host header. If JWt is configured behind a reverse proxy,
then the last entry in the HTTP X-Forwarded-Host header
field is used instead (to infer the name of the reverse proxy instead).
For HTTP 1.0 requests, the HTTP Host header is not required.
When not present, the server host name is inferred from the configured
server name, which defaults to the DNS name.
public java.lang.String getUrlScheme()
"http" or "https").
public java.lang.String getUserAgent()
The user agent, as reported in the HTTP User-Agent field.
getAgent()public java.lang.String getReferer()
The referer, as reported in the HTTP Referer field.
public java.lang.String getAccept()
The accept header, as reported in the HTTP Accept field.
public boolean agentIsSpiderBot()
Note: currently the list of know bots is quite small. This method is used internally to render the web application for optimal indexing by bots:
id and name attributes are
omitted from DOM nodes. In this way, the generated page is always exactly
the same.
public java.lang.String getServerSignature()
The value of the CGI variable SERVER_SIGNATURE.
Example:
<address>Apache Server at localhost Port 80</address>.
public java.lang.String getServerSoftware()
The value of the CGI variable SERVER_SOFTWARE.
Example: "Apache"
public java.lang.String getServerAdmin()
The value of the CGI variable SERVER_ADMIN.
Example: "root@localhost"
public java.lang.String getClientAddress()
The (most likely) IP address of the client that is connected to this session.
This is taken to be the first public address that is given in the Client-IP header, or in the X-Forwarded-For header (in case the client is behind a proxy). If none of these headers is present, the remote socket IP address is used.
public java.lang.String getInternalPath()
This is the internal path with which the application was started.
For an application deployed at "/stuff/app.wt",
the following two URLs are considered equivalent, and indicate an
internal path "/this/there":
http://www.mydomain.com/stuff/app.wt/this/there
http://www.mydomain.com/stuff/app.wt/this/there
WApplication.getBookmarkUrl(),
getDeploymentPath()public java.lang.String getDeploymentPath()
This is the path at which the application is deployed.
getInternalPath()public static java.lang.String getLibraryVersion()
Example: "1.99.2"
public java.lang.String getSessionId()
WApplication#getSessionId() instead
Retrieves the session id for this session. This is an auto-generated random alpha-numerical id, whose length is determined by settings in the configuration file.
public java.lang.String getCgiValue(java.lang.String varName)
Retrieves the value for the given CGI environment variable (like
"SSL_CLIENT_S_DN_CN"), if it is defined, otherwise
an empty string.
getServerSignature(),
getServerSoftware(),
getServerAdmin()public WEnvironment.ContentType getContentType()
This is determined by listening to the capabilities of the browser. Xhtml1 is chosen only if the browser reports support for it, and it is allowed in the configuration file (wt_config.xml).
Note that JWt makes also use of common non-standard techniques implemented in every major browser.
public WEnvironment.UserAgent getAgent()
This returns an interpretation of the getUserAgent(). It should be used only for user-agent specific
work-arounds (as a last resort).
agentIsIE(),
agentIsOpera(),
agentIsGecko(),
agentIsChrome(),
agentIsSafari(),
agentIsWebKit()public boolean agentIsIE()
getAgent()public boolean agentIsIElt(int version)
Returns whether the agent is an IE version older than the given version.
agentIsIE()public boolean agentIsIEMobile()
Returns also true when the agent is Internet Explorer 5 or
older.
getAgent()public boolean agentIsOpera()
getAgent()public boolean agentIsWebKit()
Webkit-based browsers include Safari, Chrome, Arora and Konquerer browsers.
getAgent()public boolean agentIsMobileWebKit()
Mobile Webkit-based browsers include the Android Mobile WebKit and the iPhone Mobile WebKit browsers.
getAgent()public boolean agentIsSafari()
getAgent()public boolean agentIsChrome()
getAgent()public boolean agentIsGecko()
Gecko-based browsers include Firefox.
getAgent()public WtServlet getServer()
This returns the servlet environment of this session.
public boolean hashInternalPaths()
public boolean supportsCss3Animations()
public boolean isTest()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||