|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.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 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(Document doc,
ViewContext vc)
The purpose of this method is to prepare an outgoing Document
with a scripting flag. |
static void |
prepareClientResp(HTMLDocument doc,
ViewContext vc)
The purpose of this method is to prepare an outgoing HTMLDocument
with a scripting flag. |
static String |
prepareRedirectURL(String url,
ViewCapabilities vc)
This method prepares a URL for redirect by adding the appropriate client scripting flag. |
static 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 final org.apache.log4j.Logger logger
public static boolean DETECT_CLIENT_SCRIPTING_ENABLED
public static final String SCRIPT_FLAG
Constructor Detail |
public ScriptDetector()
Method Detail |
public static boolean checkClientReq(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws 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
IOException
javax.servlet.ServletException
public static void prepareClientResp(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(Document doc, ViewContext vc) throws 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
This method claims to throw a DOMException for unsupported DOM's. However, since we don't have explicit support for WML, XHTML, or XML documents yet, we'll just let them pass unchanged rather than throw the exception. Leaving the throws clause here for future use to avoid modifying the interface.
doc
- the DOM Document
that we wish to processvc
- the ViewContext
in which this doc is to be rendered
DOMException
- - if the document passed in cannot be
cast to one of the currently supported typespublic static String prepareRedirectURL(String url, ViewCapabilities vc)
url
- the URL to redirect the client tovc
- the ViewCapabilities
of the client
public static 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 |