org.mmbase.bridge.jsp.taglib
Class ContextReferrerTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--org.mmbase.bridge.jsp.taglib.ContextReferrerTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag
Direct Known Subclasses:
CloudReferrerTag, CloudTag, ContextTag, FormatterTag, ListReferrerTag, LocaleTag, LogTag, ParamTag, PresentTag, RemoveTag, TimerTag, TimeTag, WriteTag, XsltTag

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

If you want to have attributes which obtain the value from a parameter or other context variable, or if you want to be able to refer to other tags, then your tag can extend from this one.

Author:
Michiel Meeuwissen
See Also:
ContextTag, Serialized Form

Field Summary
protected  java.lang.String contextId
           
static java.lang.String PAGE_CATEGORY
           
protected  ContextTag pageContextTag
           
protected  java.lang.String referid
           
protected  java.lang.String writerid
          Which writer to use.
 
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
ContextReferrerTag()
           
 
Method Summary
protected  javax.servlet.jsp.tagext.TagSupport findParentTag(java.lang.String classname, java.lang.String id)
           
protected  javax.servlet.jsp.tagext.TagSupport findParentTag(java.lang.String classname, java.lang.String id, boolean exception)
          Finds a parent tag by class and id.
 Writer findWriter()
          Find the parent writer tag.
 Writer findWriter(boolean th)
           
protected  java.lang.Boolean getAttributeBoolean(java.lang.String b)
          Like getAttributeValue but converts the result to a Boolean, and throws an exception if this cannot be done.
protected  java.lang.Integer getAttributeInteger(java.lang.String i)
          Like getAttributeValue but converts the result to an Integer, and throws an exception if this cannot be done.
protected  java.lang.Integer getAttributeInteger(java.lang.String i, int def)
           
 java.lang.String getAttributeValue(java.lang.String attribute)
          Call this function in your set-attribute function.
 ContextTag getContextTag()
          Finds the parent context tag.
protected  java.lang.Object getObject(java.lang.String key)
          Gets an object from the Context.
protected  java.lang.String getReferid()
           
protected  java.lang.String getString(java.lang.String key)
          Gets an object from the Context, and returns it as a String.
 void release()
          Release all allocated resources.
 void setContext(java.lang.String c)
          Refer to a specific context.
 void setPageContext(javax.servlet.jsp.PageContext pc)
           
 void setReferid(java.lang.String r)
          ContextReferrers normally can have the attribute 'referid'.
 void setWriter(java.lang.String w)
          Sets the writer attribute.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doEndTag, doInitBody, doStartTag, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, 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, setParent
 

Field Detail

PAGE_CATEGORY

public static final java.lang.String PAGE_CATEGORY

pageContextTag

protected ContextTag pageContextTag

contextId

protected java.lang.String contextId

referid

protected java.lang.String referid

writerid

protected java.lang.String writerid
Which writer to use.
Constructor Detail

ContextReferrerTag

public ContextReferrerTag()
Method Detail

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pc)
Overrides:
setPageContext in class javax.servlet.jsp.tagext.TagSupport

setReferid

public void setReferid(java.lang.String r)
                throws javax.servlet.jsp.JspTagException
ContextReferrers normally can have the attribute 'referid'. If a ContextReferrer has the 'id' attribute it registers its output in the surrounding Context. With 'referid' you can 'repeat' a tag which had the 'id' attribute.

getReferid

protected java.lang.String getReferid()
                               throws javax.servlet.jsp.JspTagException

findWriter

public Writer findWriter()
                  throws javax.servlet.jsp.JspTagException
Find the parent writer tag. It also calls haveBody on this parent tag, so that this knows that it has a body. If a write-tag has a body, then on default it will not write itself, but only communicate itself tot the body's tags.

findWriter

public Writer findWriter(boolean th)
                  throws javax.servlet.jsp.JspTagException
Since:
MMBase-1.6.2

setWriter

public void setWriter(java.lang.String w)
               throws javax.servlet.jsp.JspTagException
Sets the writer attribute.

release

public void release()
Release all allocated resources.
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

setContext

public void setContext(java.lang.String c)
Refer to a specific context. With this you can refer to, and write in, another context then the direct parent (but is must be an ancestor). This is for analogy with other attributes like this.

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String attribute)
                                   throws javax.servlet.jsp.JspTagException
Call this function in your set-attribute function. It makes it possible for the user of the taglib to include ids of values stored in the context. The method replaces all occurrences of ${x} and $x, where x is a reference to a attribute value, possibly prefixed with context names. The end of the variable if determined by the closing bracket (${x}) or by the first non ContextIndentifierChar or end of string ($x). Simple aritmetic is possible with ${+...}, and since you can even use $-vars inside ${}, you can do in this way some arithmetic on variables.

getAttributeBoolean

protected java.lang.Boolean getAttributeBoolean(java.lang.String b)
                                         throws javax.servlet.jsp.JspTagException
Like getAttributeValue but converts the result to a Boolean, and throws an exception if this cannot be done.

getAttributeInteger

protected java.lang.Integer getAttributeInteger(java.lang.String i)
                                         throws javax.servlet.jsp.JspTagException
Like getAttributeValue but converts the result to an Integer, and throws an exception if this cannot be done. It the incoming string evaluates to an empty string, then it will return 0, unless the second optional parameter specifies another default value;

getAttributeInteger

protected java.lang.Integer getAttributeInteger(java.lang.String i,
                                                int def)
                                         throws javax.servlet.jsp.JspTagException

findParentTag

protected final javax.servlet.jsp.tagext.TagSupport findParentTag(java.lang.String classname,
                                                                  java.lang.String id,
                                                                  boolean exception)
                                                           throws javax.servlet.jsp.JspTagException
Finds a parent tag by class and id. This is a base function for 'getContext', but it is handy in itself, so also available for extended classes.
Parameters:
classname - the classname of the Tag to find.
id - the id of the Tag to find.
exception - if it has to throw an exception if the parent can not be found (default: yes).

findParentTag

protected final javax.servlet.jsp.tagext.TagSupport findParentTag(java.lang.String classname,
                                                                  java.lang.String id)
                                                           throws javax.servlet.jsp.JspTagException

getContextTag

public ContextTag getContextTag()
                         throws javax.servlet.jsp.JspTagException
Finds the parent context tag.

getObject

protected java.lang.Object getObject(java.lang.String key)
                              throws javax.servlet.jsp.JspTagException
Gets an object from the Context.

getString

protected java.lang.String getString(java.lang.String key)
                              throws javax.servlet.jsp.JspTagException
Gets an object from the Context, and returns it as a String. This is not always a simple 'toString'. For example a getString on a Node will return the number, which also uniquely identifies it. If the object is 'not present' then it returns an empty string.


MMBase build 1.6.5.20030923