org.mmbase.bridge.jsp.taglib
Class AbstractNodeListTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended byorg.mmbase.bridge.jsp.taglib.ContextReferrerTag
              extended byorg.mmbase.bridge.jsp.taglib.CloudReferrerTag
                  extended byorg.mmbase.bridge.jsp.taglib.NodeReferrerTag
                      extended byorg.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
                          extended byorg.mmbase.bridge.jsp.taglib.AbstractNodeListTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, ContextProvider, FunctionContainerOrNodeProvider, javax.servlet.jsp.tagext.IterationTag, ListProvider, NodeProvider, QueryContainerOrListProvider, java.io.Serializable, javax.servlet.jsp.tagext.Tag, TagIdentifier
Direct Known Subclasses:
ListNodesTag, ListRelationsTag, ListTag, RelatedNodesTag, TreeTag, WhoTag

public abstract class AbstractNodeListTag
extends AbstractNodeProviderTag
implements javax.servlet.jsp.tagext.BodyTag, ListProvider

AbstractNodeListTag, provides basic functionality for listing objects stored in MMBase

Version:
$Id: AbstractNodeListTag.java,v 1.63 2004/03/24 00:59:01 michiel Exp $
Author:
Kees Jongenburger, Michiel Meeuwissen, Pierre van Rooden
See Also:
Serialized Form

Nested Class Summary
protected static class AbstractNodeListTag.NodesAndTrim
           
 
Field Summary
protected  Attribute constraints
          Holds the clause used to filter the list.
protected  Attribute directions
          Holds the direction to sort the list on (per field in orderby).
protected  NodeListHelper listHelper
           
protected static int NOT_HANDLED
           
protected  Attribute orderby
          Holds the list of fields to sort the list on.
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
nodeHelper
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.NodeReferrerTag
parentNodeId
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
contextId, EVAL_BODY, helper, id, pageContextTag, referid, writerid
 
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
AbstractNodeListTag()
           
 
Method Summary
 int doAfterBody()
          Does everything needed on the afterbody tag of every NodeProvider.
 int doEndTag()
           
protected  int doStartTagHelper()
           
 ContextContainer getContextContainer()
           
 java.lang.Object getCurrent()
           
 int getIndex()
           
 int getIndexOffset()
           
protected  AbstractNodeListTag.NodesAndTrim getNodesAndTrim(Query query)
           
protected  AbstractNodeListTag.NodesAndTrim getNodesAndTrim(Query query, int more)
           
protected  NodeList getReturnList()
           
 boolean isChanged()
          If you order a list, then the 'changed' property will be true if the field on which you order changed value.
 void remove()
          Removes the current item from the list.
 void setComparator(java.lang.String c)
           
 void setConstraints(java.lang.String where)
          Sets the selection query
 void setDirections(java.lang.String directions)
          Sets the direction to sort on
 void setMax(java.lang.String max)
          Set the list maximum
 void setOffset(java.lang.String o)
          Set the list offset
 void setOrderby(java.lang.String orderby)
          Sets the fields to sort on.
protected  int setReturnValues(NodeList nodes)
          Creates the node iterator and sets appropriate variables (such as listsize) from a passed node list.
protected  int setReturnValues(NodeList nodes, boolean trim)
          Creates the node iterator and sets appropriate variables (such as listsize).
 int size()
           
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
fillVars, getModified, getNodeVar, setJspvar, setModified, setNodeVar
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.NodeReferrerTag
findNodeProvider, findNodeProvider, getNode, setNode
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.CloudReferrerTag
findCloudProvider, findCloudProvider, getCloud, getCloudContext, getCloudVar, getNode, getNodeOrNull, setCloud
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
findParentTag, findParentTag, findParentTag, findParentTag, findWriter, findWriter, getAttribute, getAttributeBoolean, getAttributeInteger, getAttributeInteger, getAttributeValue, getContentTag, getContextProvider, getContextTag, getId, getLocale, getObject, getPageContext, getReferid, getString, getWriterValue, haveBody, release, setContext, setEscape, setId, setPageContext, setReferid, setVartype, setWrite, setWriter
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
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.BodyTag
doInitBody, setBodyContent
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doStartTag, getParent, release, setPageContext, setParent
 
Methods inherited from interface org.mmbase.bridge.jsp.taglib.TagIdentifier
getId
 

Field Detail

orderby

protected Attribute orderby
Holds the list of fields to sort the list on. The sort itself is implementation specific.


directions

protected Attribute directions
Holds the direction to sort the list on (per field in orderby). The sort itself is implementation specific.


constraints

protected Attribute constraints
Holds the clause used to filter the list. This is either a SQL-clause, with MMBase fields in brackets, a altavista-like search, preceded with the keyword ALTA, or a MMBase database node search, preceded with the keyord MMNODE. The filter itself is implementation specific (not all lists may implement this!).


listHelper

protected NodeListHelper listHelper

NOT_HANDLED

protected static int NOT_HANDLED
Constructor Detail

AbstractNodeListTag

public AbstractNodeListTag()
Method Detail

getReturnList

protected NodeList getReturnList()

getCurrent

public java.lang.Object getCurrent()
Specified by:
getCurrent in interface ListProvider
Returns:
the current item in a list

getIndex

public int getIndex()
Specified by:
getIndex in interface ListProvider
Returns:
the index of the current item in a list

getIndexOffset

public int getIndexOffset()
Specified by:
getIndexOffset in interface ListProvider
Returns:
The offset of the index (normally this will return 1)

remove

public void remove()
Description copied from interface: ListProvider
Removes the current item from the list.

Specified by:
remove in interface ListProvider

setOrderby

public void setOrderby(java.lang.String orderby)
                throws javax.servlet.jsp.JspTagException
Sets the fields to sort on.

Parameters:
orderby - A comma separated list of fields on which the returned nodes should be sorted
Throws:
javax.servlet.jsp.JspTagException

setDirections

public void setDirections(java.lang.String directions)
                   throws javax.servlet.jsp.JspTagException
Sets the direction to sort on

Parameters:
directions - the selection query for the object we are looking for direction
Throws:
javax.servlet.jsp.JspTagException

setMax

public void setMax(java.lang.String max)
            throws javax.servlet.jsp.JspTagException
Set the list maximum

Parameters:
max - the max number of values returned
Throws:
javax.servlet.jsp.JspTagException

setOffset

public void setOffset(java.lang.String o)
               throws javax.servlet.jsp.JspTagException
Set the list offset

Parameters:
o - Offset for the returned list.
Throws:
javax.servlet.jsp.JspTagException

setComparator

public void setComparator(java.lang.String c)
                   throws javax.servlet.jsp.JspTagException
Throws:
javax.servlet.jsp.JspTagException

setConstraints

public void setConstraints(java.lang.String where)
                    throws javax.servlet.jsp.JspTagException
Sets the selection query

Parameters:
where - the selection query
Throws:
javax.servlet.jsp.JspTagException

getNodesAndTrim

protected final AbstractNodeListTag.NodesAndTrim getNodesAndTrim(Query query)
                                                          throws javax.servlet.jsp.JspTagException
Throws:
javax.servlet.jsp.JspTagException

getNodesAndTrim

protected AbstractNodeListTag.NodesAndTrim getNodesAndTrim(Query query,
                                                           int more)
                                                    throws javax.servlet.jsp.JspTagException
Parameters:
more - How many more than max must be queried (if something will be subtracted later)
Returns:
true If successful
Throws:
javax.servlet.jsp.JspTagException
Since:
MMBase-1.7

getContextContainer

public ContextContainer getContextContainer()
                                     throws javax.servlet.jsp.JspTagException
Specified by:
getContextContainer in interface ContextProvider
Throws:
javax.servlet.jsp.JspTagException

doStartTagHelper

protected int doStartTagHelper()
                        throws javax.servlet.jsp.JspTagException
Throws:
javax.servlet.jsp.JspTagException

setReturnValues

protected int setReturnValues(NodeList nodes)
                       throws javax.servlet.jsp.JspTagException
Creates the node iterator and sets appropriate variables (such as listsize) from a passed node list. The list is assumed to be already sorted and trimmed.

Parameters:
nodes - the nodelist to create the iterator from
Returns:
EVAL_BODY_BUFFERED if the resulting list is not empty, SKIP_BODY if the list is empty. THis value should be passed as the result of {
Throws:
javax.servlet.jsp.JspTagException

setReturnValues

protected int setReturnValues(NodeList nodes,
                              boolean trim)
                       throws javax.servlet.jsp.JspTagException
Creates the node iterator and sets appropriate variables (such as listsize). Takes a node list, and trims it using the offset and max attributes if so indicated. The list is assumed to be already sorted.

Parameters:
nodes - the nodelist to create the iterator from
trim - if true, trim the list using offset and max (if false, it is assumed the calling routine already did so)
Returns:
EVAL_BODY_BUFFERED if the resulting list is not empty, SKIP_BODY if the list is empty. This value should be passed as the result of BodyTagSupport.doStartTag().
Throws:
javax.servlet.jsp.JspTagException

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspTagException
Description copied from class: AbstractNodeProviderTag
Does everything needed on the afterbody tag of every NodeProvider. Normally this function would be overrided with one that has to call super.doAfterBody(). But not all servlet engines to call this function if there is no body. So, in that case it should be called from doEndTag, if the tag can do something without a body.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class AbstractNodeProviderTag
Throws:
javax.servlet.jsp.JspTagException

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspTagException
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class AbstractNodeProviderTag
Throws:
javax.servlet.jsp.JspTagException

isChanged

public boolean isChanged()
If you order a list, then the 'changed' property will be true if the field on which you order changed value.

Specified by:
isChanged in interface ListProvider
Returns:
a boolean indicating wether the field on which was sorted is changed.

size

public int size()
Specified by:
size in interface ListProvider
Returns:
the size of the list


MMBase build 1.7.1.20041002