net.sourceforge.ajaxtags.tags
Class BaseAjaxBodyTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by net.sourceforge.ajaxtags.tags.BaseAjaxBodyTag
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:
AjaxAnchorsTag, AjaxTabPanelTag, BaseAjaxTag

public abstract class BaseAjaxBodyTag
extends javax.servlet.jsp.tagext.BodyTagSupport

This is a base class that will help to make a development of any tag really easy

See Also:
Serialized Form

Field Summary
static String AJAX_VOID_URL
           
static String HEADER_FLAG
           
static String HEADER_FLAG_VALUE
           
static String JSCLASS_BASE
          Common prefix for all JavaScript class names.
 
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
BaseAjaxBodyTag()
           
 
Method Summary
 JavaScript buildScript()
          Generate JavaScript for tag.
 int doStartTag()
           
 String getAttachTo()
           
 String getBaseUrl()
           
protected  String getBody()
           
 String getErrorFunction()
           
 String getEventType()
           
protected  String getHttpRequestHeader(String headerName)
           
protected  javax.servlet.http.HttpServletRequest getHttpServletRequest()
           
protected  javax.servlet.http.HttpServletResponse getHttpServletResponse()
           
protected  String getJsClass()
          Return JavaScript class for JavaScript class corresponding to this tag (e.g.
 String getJSVariable()
          Build JavaScript assignment string.
protected  String getOnclickAjax(String target, String href, OptionsBuilder opt)
          Helper to define new AJAX updater for onclick attribute.
protected  OptionsBuilder getOptions()
          Options for JavaScript generation.
protected  OptionsBuilder getOptionsBuilder()
           
protected  OptionsBuilder getOptionsBuilder(boolean empty)
           
 String getParameters()
           
 String getParser()
           
 String getPostFunction()
           
 String getPreFunction()
           
 String getSource()
           
 String getSourceClass()
           
 String getStyleClass()
           
 String getTarget()
           
 String getVar()
           
protected  void initParameters()
           
protected  boolean isAjaxRequest()
          Detect if the client does an AJAX call or not.
protected  boolean isHttpRequestHeader(String headerName, String headerValue)
           
protected  void out(CharSequence csec)
           
 void release()
           
protected  void releaseTag()
          Never call release() from releaseTag() -> ends in loop.
 void setAttachTo(String attachTo)
           
 void setBaseUrl(String baseUrl)
           
 void setErrorFunction(String errorFunction)
           
 void setEventType(String eventType)
           
 void setParameters(String parameters)
           
 void setParser(String parser)
           
 void setPostFunction(String postFunction)
           
 void setPreFunction(String preFunction)
           
 void setSource(String source)
           
 void setSourceClass(String sourceClass)
           
 void setStyleClass(String styleClass)
           
 void setTarget(String target)
           
 void setVar(String var)
           
protected  void skipBody()
          Ignore the body of the tag.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doEndTag, 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

HEADER_FLAG

public static final String HEADER_FLAG
See Also:
Constant Field Values

HEADER_FLAG_VALUE

public static final String HEADER_FLAG_VALUE
See Also:
Constant Field Values

AJAX_VOID_URL

public static final String AJAX_VOID_URL
See Also:
Constant Field Values

JSCLASS_BASE

public static final String JSCLASS_BASE
Common prefix for all JavaScript class names.

See Also:
Constant Field Values
Constructor Detail

BaseAjaxBodyTag

public BaseAjaxBodyTag()
Method Detail

getHttpServletRequest

protected javax.servlet.http.HttpServletRequest getHttpServletRequest()

getHttpServletResponse

protected javax.servlet.http.HttpServletResponse getHttpServletResponse()

isHttpRequestHeader

protected boolean isHttpRequestHeader(String headerName,
                                      String headerValue)

getHttpRequestHeader

protected String getHttpRequestHeader(String headerName)

isAjaxRequest

protected boolean isAjaxRequest()
Detect if the client does an AJAX call or not.

Returns:
true only if the client send the header with XMLHttpRequest

out

protected void out(CharSequence csec)
            throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException

skipBody

protected final void skipBody()
Ignore the body of the tag.


doStartTag

public final int doStartTag()
                     throws javax.servlet.jsp.JspException
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

release

public final void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

getEventType

public final String getEventType()

setEventType

public final void setEventType(String eventType)

getSourceClass

public final String getSourceClass()

setSourceClass

public final void setSourceClass(String sourceClass)

getSource

public final String getSource()

setSource

public final void setSource(String source)
Parameters:
source - ID of the source element

getVar

public final String getVar()

setVar

public final void setVar(String var)

setAttachTo

public final void setAttachTo(String attachTo)

getAttachTo

public final String getAttachTo()

getStyleClass

public final String getStyleClass()
Returns:
Returns the styleClass.

setStyleClass

public final void setStyleClass(String styleClass)
Parameters:
styleClass - The styleClass to set.

getJSVariable

public final String getJSVariable()
Build JavaScript assignment string.

Returns:
String with left side of assignment to variable "var foo = " or field "object.foo = "

getJsClass

protected String getJsClass()
Return JavaScript class for JavaScript class corresponding to this tag (e.g. "AjaxJspTag.Submit" for AjaxSubmitTag Java tag).

Returns:
String with JavaScript class suffix

getOptions

protected OptionsBuilder getOptions()
Options for JavaScript generation.

Returns:
default options

buildScript

public JavaScript buildScript()
Generate JavaScript for tag.

Returns:
JavaScript

getParameters

public final String getParameters()

setParameters

public final void setParameters(String parameters)

getErrorFunction

public final String getErrorFunction()

setErrorFunction

public final void setErrorFunction(String errorFunction)

getPostFunction

public final String getPostFunction()

setPostFunction

public final void setPostFunction(String postFunction)

getPreFunction

public final String getPreFunction()

setPreFunction

public final void setPreFunction(String preFunction)

getParser

public final String getParser()

setParser

public final void setParser(String parser)

getBaseUrl

public final String getBaseUrl()

setBaseUrl

public final void setBaseUrl(String baseUrl)

getTarget

public final String getTarget()
Returns:
Returns the target.

setTarget

public final void setTarget(String target)
Parameters:
target - The target to set.

initParameters

protected void initParameters()
                       throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException

releaseTag

protected void releaseTag()
Never call release() from releaseTag() -> ends in loop.


getOptionsBuilder

protected OptionsBuilder getOptionsBuilder()
Returns:
the OptionsBuilder with non-empty subset of default options (baseUrl, parser, target, source, sourceClass, eventType, parameters, onCreate, onComplete, onFailure)

getOptionsBuilder

protected OptionsBuilder getOptionsBuilder(boolean empty)
Parameters:
empty - true to return empty OptionsBuilder (without any options), false to return OptionsBuilder with non-empty subset of default options (baseUrl, parser, target, source, sourceClass, eventType, parameters, onCreate, onComplete, onFailure)
Returns:
the OptionsBuilder

getOnclickAjax

protected final String getOnclickAjax(String target,
                                      String href,
                                      OptionsBuilder opt)
Helper to define new AJAX updater for onclick attribute.

Parameters:
target - the target to request
href - the URL
opt - options for javascript library
Returns:
the javascript code to do AJAX update

getBody

protected String getBody()
Returns:
String representation of current body content or null


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