org.mmbase.bridge.jsp.taglib
Class ContextReferrerTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended byorg.mmbase.bridge.jsp.taglib.ContextReferrerTag
All Implemented Interfaces:
BodyTag, IterationTag, Serializable, Tag
Direct Known Subclasses:
BranchTag, CloudReferrerTag, CloudTag, ContextTag, EscaperTag, HasPageTag, ImportTag, LeafConstraintsTag, ListReferrerTag, LogTag, ParamTag, PresentTag, RemoveTag, TimerTag, TimeTag, ValidTag, WriteTag, XsltTag

public abstract class ContextReferrerTag
extends 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.

Version:
$Id: ContextReferrerTag.java,v 1.86 2006/07/14 13:26:01 nklasens Exp $
Author:
Michiel Meeuwissen
See Also:
ContextTag, Serialized Form

Field Summary
protected  Attribute contextId
           
static int EVAL_BODY
          EVAL_BODY is EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED.
protected  WriterHelper helper
          The helper member is only used by 'Writer' extensions.
protected  Attribute id
           
protected  ContextTag pageContextTag
           
protected  Attribute referid
           
protected  Attribute writerid
          Which writer to use.
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
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
 int doEndTag()
           
protected  void fillStandardParameters(Parameters p)
           
 Tag findLoopOrQuery(String tagId, boolean exception)
           
protected  TagSupport findParentTag(Class clazz, String id)
           
 TagSupport findParentTag(Class clazz, String tagId, boolean exception)
          Finds a parent tag by class and id.
protected  TagSupport findParentTag(String classname, String id)
          Deprecated.  
protected  TagSupport findParentTag(String classname, String id, boolean exception)
          Deprecated.  
 Writer findWriter()
          Find the parent writer tag.
 Writer findWriter(boolean th)
           
 Attribute getAttribute(String attribute)
           
protected  Boolean getAttributeBoolean(String b)
          Like getAttributeValue but converts the result to a Boolean, and throws an exception if this cannot be done.
protected  Integer getAttributeInteger(String i)
          Like getAttributeValue but converts the result to an Integer, and throws an exception if this cannot be done.
protected  Integer getAttributeInteger(String i, int def)
           
 String getAttributeValue(String attribute)
          Deprecated. Call getAttribute in the set-method and 'toString(tag)' when using it. This is better for perfomrnace and makes sure the impl. works in all servlet containers.
 ContentTag getContentTag()
          Returns the content-tag in which this context-referrer is in, or a default (compatible with MMBase 1.6) if there is none.
 ContextProvider getContextProvider()
          Finds the parent context provider.
 ContextTag getContextTag()
          Finds the parent context tag.
 Locale getDefaultLocale()
           
protected  Object getEscapedValue(Object value)
          Returns the escaped value associated with this tag, but only if the escape attribute was set explicitely (so not when only inherited from content-tag).
 String getId()
           
 Locale getLocale()
           
 Object getObject(String key)
          Gets an object from the Context.
 Object getObjectConditional(String key)
          Support '[key]?', which returns the object with name [key] if it is present, or simply null otherwise.
 PageContext getPageContext()
           
protected  ContextTag getPageContextTag()
           
protected  String getReferid()
           
protected  String getString(String key)
          Gets an object from the Context, and returns it as a String.
protected static String getTaglibVersion()
           
 TimeZone getTimeZone()
           
 Object getWriterValue()
           
 void haveBody()
           
 void release()
          Release all allocated resources.
 void setContext(String c)
          Refer to a specific context.
 void setEscape(String e)
           
 void setId(String i)
           
 void setJspvar(String j)
           
 void setListdelimiter(String l)
           
 void setPageContext(PageContext pc)
           
 void setReferid(String r)
          ContextReferrers normally can have the attribute 'referid'.
 void setVartype(String t)
           
 void setWrite(String w)
           
 void setWriter(String w)
          Sets the writer attribute.
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, doStartTag, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, 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

EVAL_BODY

public static int EVAL_BODY
EVAL_BODY is EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED. It wants to be EVAL_BODY_INCLUDE, but because that often not works, it on default is EVAL_BODY_BUFFERED. This configurable constant might become deprecated, because it is a bit experimental.


pageContextTag

protected ContextTag pageContextTag

contextId

protected Attribute contextId

referid

protected Attribute referid

id

protected Attribute id

writerid

protected Attribute writerid
Which writer to use.


helper

protected final WriterHelper helper
The helper member is only used by 'Writer' extensions.

Constructor Detail

ContextReferrerTag

public ContextReferrerTag()
Method Detail

getTaglibVersion

protected static String getTaglibVersion()

getPageContext

public PageContext getPageContext()

getPageContextTag

protected ContextTag getPageContextTag()
Since:
MMBase-1.7.4

setPageContext

public void setPageContext(PageContext pc)

setReferid

public void setReferid(String r)
                throws 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.

Throws:
JspTagException

setId

public void setId(String i)

getId

public String getId()

getReferid

protected String getReferid()
                     throws JspTagException
Throws:
JspTagException

findWriter

public Writer findWriter()
                  throws 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.

Throws:
JspTagException

findWriter

public Writer findWriter(boolean th)
                  throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.6.2

setWriter

public void setWriter(String w)
               throws JspTagException
Sets the writer attribute.

Throws:
JspTagException

doEndTag

public int doEndTag()
             throws JspTagException
Throws:
JspTagException

release

public void release()
Release all allocated resources.


setContext

public void setContext(String c)
                throws JspTagException
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.

Throws:
JspTagException

getAttributeValue

public String getAttributeValue(String attribute)
                         throws JspTagException
Deprecated. Call getAttribute in the set-method and 'toString(tag)' when using it. This is better for perfomrnace and makes sure the impl. works in all servlet containers.

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.

Throws:
JspTagException

getAttribute

public Attribute getAttribute(String attribute)
                       throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.6.1

getAttributeBoolean

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

Throws:
JspTagException

getAttributeInteger

protected Integer getAttributeInteger(String i)
                               throws 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;

Throws:
JspTagException

getAttributeInteger

protected Integer getAttributeInteger(String i,
                                      int def)
                               throws JspTagException
Throws:
JspTagException

findParentTag

protected final TagSupport findParentTag(String classname,
                                         String id,
                                         boolean exception)
                                  throws JspTagException
Deprecated.  

Throws:
JspTagException
See Also:
findParentTag(Class, String, boolean)

findParentTag

public final TagSupport findParentTag(Class clazz,
                                      String tagId,
                                      boolean exception)
                               throws 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:
clazz - the class of the Tag to find.
tagId - the id of the Tag to find.
exception - if it has to throw an exception if the parent can not be found (default: yes).
Throws:
JspTagException
Since:
MMBase-1.7

findLoopOrQuery

public Tag findLoopOrQuery(String tagId,
                           boolean exception)
                    throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.8

findParentTag

protected final TagSupport findParentTag(String classname,
                                         String id)
                                  throws JspTagException
Deprecated.  

Throws:
JspTagException

findParentTag

protected final TagSupport findParentTag(Class clazz,
                                         String id)
                                  throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7

getContextProvider

public ContextProvider getContextProvider()
                                   throws JspTagException
Finds the parent context provider.

Throws:
JspTagException
Since:
MMBase-1.7

getContextTag

public ContextTag getContextTag()
                         throws JspTagException
Finds the parent context tag. In MMBase 1.7 and higher, normally you would like to use getContextProvider in stead.

Throws:
JspTagException

getObject

public Object getObject(String key)
                 throws JspTagException
Gets an object from the Context.

Throws:
JspTagException

getObjectConditional

public Object getObjectConditional(String key)
                            throws JspTagException
Support '[key]?', which returns the object with name [key] if it is present, or simply null otherwise. If not ends with ?, it simply behaves like getObject(String).

Throws:
JspTagException
Since:
MMBase-1.8.1

getString

protected String getString(String key)
                    throws 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.

Throws:
JspTagException

getContentTag

public ContentTag getContentTag()
                         throws JspTagException
Returns the content-tag in which this context-referrer is in, or a default (compatible with MMBase 1.6) if there is none.

Throws:
JspTagException
Since:
MMBase-1.7

getLocale

public Locale getLocale()
                 throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7.1

getDefaultLocale

public Locale getDefaultLocale()

getTimeZone

public TimeZone getTimeZone()
Since:
MMBase-1.8

fillStandardParameters

protected void fillStandardParameters(Parameters p)
                               throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.7.4

setVartype

public void setVartype(String t)
                throws JspTagException
Throws:
JspTagException

setListdelimiter

public final void setListdelimiter(String l)
                            throws JspTagException
Throws:
JspTagException
Since:
MMBase-1.8

setJspvar

public void setJspvar(String j)

setWrite

public final void setWrite(String w)
                    throws JspTagException
Throws:
JspTagException

setEscape

public final void setEscape(String e)
                     throws JspTagException
Throws:
JspTagException

getWriterValue

public final Object getWriterValue()

haveBody

public final void haveBody()

getEscapedValue

protected Object getEscapedValue(Object value)
                          throws JspTagException
Returns the escaped value associated with this tag, but only if the escape attribute was set explicitely (so not when only inherited from content-tag).

Throws:
JspTagException
Since:
MMBase-1.8


MMBase build 1.8.1.20060716