net.sourceforge.ajaxtags.tags
Class AjaxAnchorsTag

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
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:
AjaxAreaTag

public class AjaxAnchorsTag
extends BaseAjaxBodyTag

Rewrites HTML anchor tags (<A>), replacing the href attribute with an onclick event so that retrieved content is loaded inside a region on the page.

See Also:
Serialized Form

Field Summary
 
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
AjaxAnchorsTag()
           
 
Method Summary
 String ajaxAnchors(String html, String target, String clazz)
          Rewrite anchors.
 int doEndTag()
          rewrite the body and make use of ajax. rewriting all <a> links to use javascript calls to prototype.
protected static Document getDocument(String html)
          Parse XHTML document from given string.
protected  void rewriteLink(Node link, String target)
          Rewrite link.
 
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, initParameters, isAjaxRequest, isHttpRequestHeader, out, release, releaseTag, 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
 

Constructor Detail

AjaxAnchorsTag

public AjaxAnchorsTag()
Method Detail

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
rewrite the body and make use of ajax. rewriting all <a> links to use javascript calls to prototype.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_PAGE
Throws:
javax.servlet.jsp.JspException

ajaxAnchors

public String ajaxAnchors(String html,
                          String target,
                          String clazz)
                   throws javax.servlet.jsp.JspException
Rewrite anchors.

Parameters:
html - XHTML source
target - target of request
clazz - CSS class of anchors
Returns:
rewritten and reformatted XHTML text
Throws:
javax.servlet.jsp.JspException - on errors

rewriteLink

protected final void rewriteLink(Node link,
                                 String target)
Rewrite link. Change (or create) "onclick" attribute, set "href" attribute to "javascript://nop/".

Parameters:
link - node of document with link
target - target of request

getDocument

protected static final Document getDocument(String html)
                                     throws SAXException
Parse XHTML document from given string.

Parameters:
html - string with XHTML content
Returns:
parsed document or null
Throws:
SAXException - if string cannot be parsed


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