|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.barracuda.core.helper.servlet.ScriptDetector
This class simply detects whether or not the client has scripting enabled.
Field Summary | |
static boolean |
DETECT_CLIENT_SCRIPTING_ENABLED
Flag indicating whether or not to check for client-side scripting |
protected static org.apache.log4j.Logger |
logger
|
static java.lang.String |
SCRIPT_FLAG
Flag added to URL's and Forms and sent with requests allowing the server to determine if the client supports scripting |
Constructor Summary | |
ScriptDetector()
|
Method Summary | |
static boolean |
checkClientReq(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
This method checks an incoming request to see if it has a scripting flag which indicates whether or not the client supports scripting. |
static void |
prepareClientResp(org.w3c.dom.Document doc,
ViewContext vc)
The purpose of this method is to prepare an outgoing Document
with a scripting flag. |
static void |
prepareClientResp(org.w3c.dom.html.HTMLDocument doc,
ViewContext vc)
The purpose of this method is to prepare an outgoing HTMLDocument
with a scripting flag. |
static java.lang.String |
prepareRedirectURL(java.lang.String url,
ViewCapabilities vc)
This method prepares a URL for redirect by adding the appropriate client scripting flag. |
static java.lang.Boolean |
scriptingEnabled(javax.servlet.http.HttpServletRequest req)
This method evaluates a client request to see whether or not scripting is enabled (based on the presence of the SCRIPT_FLAG in the parameters). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger logger
public static boolean DETECT_CLIENT_SCRIPTING_ENABLED
public static final java.lang.String SCRIPT_FLAG
Constructor Detail |
public ScriptDetector()
Method Detail |
public static boolean checkClientReq(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException, javax.servlet.ServletException
Right now, we only call this method if we are handling a GET request (the assumption being that if the client is POSTing data, it probably came from the server in the first place and, thus, should already have the script flag).
req
- the servlet requestresp
- the servlet response
true
if we actually wrote a response
java.io.IOException
javax.servlet.ServletException
public static void prepareClientResp(org.w3c.dom.html.HTMLDocument doc, ViewContext vc)
HTMLDocument
with a scripting flag. This ensures that, upon follow-up requests,
client scripting support can be determined.
This method adjusts all links and forms with a flag marking the client as not supporting scripting. In the case of links it adds the flag to the query string and in the case of forms, a hidden field. When the page is rendered on the client, if the client supports scripting, a script is invoked which re-sets the value of flags to indicate that scripting is supported.
Note that this method should not be called until AFTER all standard DOM manipulation has been completed (in other words, think of this as a filter that should be applied right before the final page gets sent back to the client).
doc
- the DOM HTMLDocument
that we wish to processvc
- the ViewContext
in which this doc is to be renderedpublic static void prepareClientResp(org.w3c.dom.Document doc, ViewContext vc) throws org.w3c.dom.DOMException
Document
with a scripting flag. This ensures that, upon follow-up requests,
client scripting support can be determined.
Note that it is preferable to send a specific type of document
to this method such as an HTMLDocument
or a
WMLDocument
since they provide the advantage of
compile-time checking for the type where here, given a generic
Document
, we use instanceof
to check the
type of document and then cast Document
to the appropriate
document type. For instance, use the prepareClientResp(HTMLDocument, ViewContext)
form if you have an HTMLDocument
to prepare
doc
- the DOM Document
that we wish to processvc
- the ViewContext
in which this doc is to be rendered
org.w3c.dom.DOMException
- - if the document passed in cannot be
cast to one of the currently supported types
javax.servlet.ServletException
public static java.lang.String prepareRedirectURL(java.lang.String url, ViewCapabilities vc)
url
- the URL to redirect the client tovc
- the ViewCapabilities
of the client
public static java.lang.Boolean scriptingEnabled(javax.servlet.http.HttpServletRequest req)
req
- the servlet request
true
if we can tell for sure that the client
has scripting enabled, false
if we know for
sure that it does not, and null
if we cannot
determine for sure
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |