org.mmbase.bridge.jsp.taglib
Class ContextReferrerTag

org.mmbase.bridge.jsp.taglib.ContextReferrerTag
Direct Known Subclasses:
CloudReferrerTag, CloudTag, ContextTag, ListReferrerTag, ParamTag, PresentTag, RemoveTag, TimerTag, WriteTag

public abstract class ContextReferrerTag

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

Field Summary
protected  java.lang.String contextId
           
static java.lang.String PAGE_CATEGORY
           
protected  ContextTag pageContextTag
           
protected  java.lang.String referid
           
 
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.
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.
protected  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'.
 

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
Constructor Detail

ContextReferrerTag

public ContextReferrerTag()
Method Detail

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pc)

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

release

public void release()
Release all allocated resources.

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

protected 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 2002