org.mmbase.bridge.jsp.taglib
Class ContextTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--org.mmbase.bridge.jsp.taglib.ContextReferrerTag
                    |
                    +--org.mmbase.bridge.jsp.taglib.ContextTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class ContextTag
extends ContextReferrerTag

A ContextTag is like parentheses, and as such can act as a 'namespace' (if it has an id) or as 'scope' (if it doesn't).

The context can be seen as a container for variables and their values.

(ContextReferrer) Tags living under a context tag can 'register' themselves in the context (by use of the 'id' attribute') and in that way become a variable. Other tags can refer to such variables.

A ContextTag is a ContextReferrer itself too, and therefore it is possible to 'nest' contextes. And perhaps we will also make it possible to treat contextes as variables and e.g. pass them to another page as a whole.

It is also possible to put something into the Context by hand. For that you can use the `ImportTag'.

Writing out the value of a variable can be done with the `Write' Tag.

Author:
Michiel Meeuwissen
See Also:
ImportTag, WriteTag, Serialized Form

Field Summary
static int LOCATION_ATTRIBUTES
           
static int LOCATION_COOKIE
           
static int LOCATION_MULTIPART
           
static int LOCATION_NOTSET
           
static int LOCATION_PAGE
           
static int LOCATION_PARAMETERS
           
static int LOCATION_PARENT
           
static int LOCATION_SESSION
           
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
contextId, PAGE_CATEGORY, pageContextTag, referid, writerid
 
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
ContextTag()
           
 
Method Summary
 int doAfterBody()
           
 int doStartTag()
           
 java.lang.Object findAndRegister(int from, java.lang.String referid, java.lang.String newid)
           
protected  java.lang.Object findAndRegister(int from, java.lang.String referid, java.lang.String newid, boolean check)
           
 java.lang.Object findAndRegister(java.lang.String id)
           
 java.lang.Object findAndRegister(java.lang.String externid, java.lang.String newid)
          Searches a key in request, postparameters, session, parent context and registers it in this one.
 java.lang.String findAndRegisterString(java.lang.String id)
           
 byte[] getBytes(java.lang.String key)
          hmm..
 java.lang.Object getContainerObject(java.lang.String key)
           
static boolean isContextIdentifierChar(char c)
           
 boolean isPresent(java.lang.String key)
          'present' means 'not null'.
static java.lang.String locationToString(int i)
           
 void register(java.lang.String newid, java.lang.Object n)
           
 void register(java.lang.String newid, java.lang.Object n, boolean check)
          Register an Object with a key in the context.
 void registerNode(java.lang.String key, Node n)
          Precisely like 'register', only it wants a Node.
 void release()
          Release all allocated resources.
 void reregister(java.lang.String id, java.lang.Object n)
          Registers an variable again.
 void setCloudContext(CloudContext cc)
          This context can also serve as a 'cloudcontext'.
 void setPageContext(javax.servlet.jsp.PageContext pc)
           
static int stringToLocation(java.lang.String s)
           
 void unRegister(java.lang.String key)
           
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
findParentTag, findParentTag, findWriter, findWriter, getAttributeBoolean, getAttributeInteger, getAttributeInteger, getAttributeValue, getContextTag, getObject, getReferid, getString, setContext, setReferid, setWriter
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doEndTag, doInitBody, 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

LOCATION_NOTSET

public static final int LOCATION_NOTSET

LOCATION_PAGE

public static final int LOCATION_PAGE

LOCATION_PARENT

public static final int LOCATION_PARENT

LOCATION_PARAMETERS

public static final int LOCATION_PARAMETERS

LOCATION_MULTIPART

public static final int LOCATION_MULTIPART

LOCATION_SESSION

public static final int LOCATION_SESSION

LOCATION_COOKIE

public static final int LOCATION_COOKIE

LOCATION_ATTRIBUTES

public static final int LOCATION_ATTRIBUTES
Constructor Detail

ContextTag

public ContextTag()
Method Detail

stringToLocation

public static int stringToLocation(java.lang.String s)
                            throws javax.servlet.jsp.JspTagException

locationToString

public static java.lang.String locationToString(int i)

release

public void release()
Description copied from class: ContextReferrerTag
Release all allocated resources.
Overrides:
release in class ContextReferrerTag

setCloudContext

public void setCloudContext(CloudContext cc)
This context can also serve as a 'cloudcontext'. That means that the cloud context commmunicates its cloudcontext to the context.

setPageContext

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

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspTagException
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport

registerNode

public void registerNode(java.lang.String key,
                         Node n)
                  throws javax.servlet.jsp.JspTagException
Precisely like 'register', only it wants a Node.
Parameters:
key - the key (id) of the node to register
node - the node to put in the hashmap

findAndRegister

public java.lang.Object findAndRegister(int from,
                                        java.lang.String referid,
                                        java.lang.String newid)
                                 throws javax.servlet.jsp.JspTagException

findAndRegister

protected java.lang.Object findAndRegister(int from,
                                           java.lang.String referid,
                                           java.lang.String newid,
                                           boolean check)
                                    throws javax.servlet.jsp.JspTagException

findAndRegister

public java.lang.Object findAndRegister(java.lang.String externid,
                                        java.lang.String newid)
                                 throws javax.servlet.jsp.JspTagException
Searches a key in request, postparameters, session, parent context and registers it in this one. Returns null if it could not be found.

isContextIdentifierChar

public static boolean isContextIdentifierChar(char c)

register

public void register(java.lang.String newid,
                     java.lang.Object n,
                     boolean check)
              throws javax.servlet.jsp.JspTagException
Register an Object with a key in the context. If the Context is a session context, then it will be put in the session, otherwise in the hashmap.

register

public void register(java.lang.String newid,
                     java.lang.Object n)
              throws javax.servlet.jsp.JspTagException

unRegister

public void unRegister(java.lang.String key)
                throws javax.servlet.jsp.JspTagException

reregister

public void reregister(java.lang.String id,
                       java.lang.Object n)
                throws javax.servlet.jsp.JspTagException
Registers an variable again. This can be used to change the type of a variable, e.g.
Since:
MMBase-1.6

isPresent

public boolean isPresent(java.lang.String key)
                  throws javax.servlet.jsp.JspTagException
'present' means 'not null'. 'null' means 'registered, but not present'. Not registered is not present, of course.

findAndRegister

public java.lang.Object findAndRegister(java.lang.String id)
                                 throws javax.servlet.jsp.JspTagException

findAndRegisterString

public java.lang.String findAndRegisterString(java.lang.String id)
                                       throws javax.servlet.jsp.JspTagException

getContainerObject

public java.lang.Object getContainerObject(java.lang.String key)
                                    throws javax.servlet.jsp.JspTagException

getBytes

public byte[] getBytes(java.lang.String key)
                throws javax.servlet.jsp.JspTagException
hmm.. This kind of stuf must move to ImportTag, I think.

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspTagException
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport


MMBase build 1.6.5.20030923