net.sourceforge.ajaxtags.tags
Class AjaxAreaTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by net.sourceforge.ajaxtags.tags.BaseAjaxBodyTag
              extended by net.sourceforge.ajaxtags.tags.AjaxAnchorsTag
                  extended by net.sourceforge.ajaxtags.tags.AjaxAreaTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
AjaxDisplayTag

public class AjaxAreaTag
extends AjaxAnchorsTag

Wraps any area on the page (with a DIV element) so that actions within that area refresh/load inside the defined DIV region rather than inside the whole browser window.

See Also:
Serialized Form

Field Summary
static String TARGET_HEADER
          The header we are searching to detect the ajax call.
 
Fields inherited from class net.sourceforge.ajaxtags.tags.BaseAjaxBodyTag
AJAX_VOID_URL, HEADER_FLAG, HEADER_FLAG_VALUE, JSCLASS_BASE
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
AjaxAreaTag()
           
 
Method Summary
 int doEndTag()
          Write body.
 void initParameters()
          Clear page content before start of tag if we are processing AJAX request.
 boolean isAjaxAnchors()
           
 boolean isAjaxRequest()
          Detect if the client does an AJAX call or not.
protected  String processContent(String content)
          Process content.
 void releaseTag()
          Never call release() from releaseTag() -> ends in loop.
 void setAjaxAnchors(boolean ajaxAnchors)
           
 
Methods inherited from class net.sourceforge.ajaxtags.tags.AjaxAnchorsTag
ajaxAnchors, getDocument, rewriteLink
 
Methods inherited from class net.sourceforge.ajaxtags.tags.BaseAjaxBodyTag
buildScript, doStartTag, getAttachTo, getBaseUrl, getBody, getErrorFunction, getEventType, getHttpRequestHeader, getHttpServletRequest, getHttpServletResponse, getJsClass, getJSVariable, getOnclickAjax, getOptions, getOptionsBuilder, getOptionsBuilder, getParameters, getParser, getPostFunction, getPreFunction, getSource, getSourceClass, getStyleClass, getTarget, getVar, isHttpRequestHeader, out, release, setAttachTo, setBaseUrl, setErrorFunction, setEventType, setParameters, setParser, setPostFunction, setPreFunction, setSource, setSourceClass, setStyleClass, setTarget, setVar, skipBody
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

TARGET_HEADER

public static final String TARGET_HEADER
The header we are searching to detect the ajax call. This should match the id of this tag.

See Also:
Constant Field Values
Constructor Detail

AjaxAreaTag

public AjaxAreaTag()
Method Detail

isAjaxRequest

public final boolean isAjaxRequest()
Description copied from class: BaseAjaxBodyTag
Detect if the client does an AJAX call or not.

Overrides:
isAjaxRequest in class BaseAjaxBodyTag
Returns:
Returns true if we answering to AJAX request: request has proper "X-Requested-With" and "x-request-target" headers.

isAjaxAnchors

public final boolean isAjaxAnchors()
Returns:
Returns the ajaxAnchors.

setAjaxAnchors

public final void setAjaxAnchors(boolean ajaxAnchors)
Parameters:
ajaxAnchors - The ajaxAnchors to set.

initParameters

public void initParameters()
                    throws javax.servlet.jsp.JspException
Clear page content before start of tag if we are processing AJAX request.

Overrides:
initParameters in class BaseAjaxBodyTag
Throws:
javax.servlet.jsp.JspException - when HTTP response cannot be reset (has already had its status code and headers written)

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Write body. Skip the rest of the page if we are processing AJAX request.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class AjaxAnchorsTag
Returns:
SKIP_PAGE for AJAX request, EVAL_PAGE for usual request
Throws:
javax.servlet.jsp.JspException - on errors

releaseTag

public void releaseTag()
Description copied from class: BaseAjaxBodyTag
Never call release() from releaseTag() -> ends in loop.

Overrides:
releaseTag in class BaseAjaxBodyTag
See Also:
Tag.release()

processContent

protected String processContent(String content)
                         throws javax.servlet.jsp.JspException
Process content. Rewrite anchors to AJAX links if needed.

Parameters:
content - XHTML source as string
Returns:
either content with rewritten anchors or unchanged content depending on flag
Throws:
javax.servlet.jsp.JspException - when links rewriting failed
Exception


Copyright © 2005-2010 The Ajaxtags Team. All Rights Reserved.