org.mmbase.bridge.jsp.taglib
Class AbstractNodeListTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--org.mmbase.bridge.jsp.taglib.ContextReferrerTag
                    |
                    +--org.mmbase.bridge.jsp.taglib.CloudReferrerTag
                          |
                          +--org.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
                                |
                                +--org.mmbase.bridge.jsp.taglib.AbstractNodeListTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, ListItemInfo, NodeProvider, java.io.Serializable, javax.servlet.jsp.tagext.Tag, TagIdentifier
Direct Known Subclasses:
ListNodesTag, ListTag, RelatedNodesTag

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

AbstractNodeListTag, provides basic functionality for listing objects stored in MMBase

Author:
Kees Jongenburger, Michiel Meeuwissen, Pierre van Rooden
See Also:
Serialized Form

Field Summary
protected  boolean changed
          Determines whether a field in sortedString changed during iteration.
protected  int currentItemIndex
          The current item
protected  java.lang.String directionString
          Holds the direction to sort the list on (per field in sortedString).
protected  int listSize
          The actual size of the list.
protected  int max
          The maximum number of elements in a list.
protected  int offset
          The offset of the elements that are returned in a list.
protected  NodeIterator returnValues
          Data member to hold an iterationof the values to return.
protected  java.lang.String sortedString
          Holds the list of fields to sort the list on.
protected  java.lang.String whereString
          Holds the clause used to filter the list.
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
fields
 
Fields inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
pageContextTag, referid
 
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_TAG
 
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()
           
 void doInitBody()
           
abstract  int doStartTag()
           
 int getIndex()
           
 boolean isChanged()
          If you order a list, then the 'changed' property will be true if the field on which you order changed value.
 boolean isFirst()
           
 boolean isLast()
           
 void setConstraints(java.lang.String where)
          Sets the selection query
 void setDirections(java.lang.String directions)
          Sets the direction to sort on
 void setMax(int m)
          Sets the list maximum with an integer argument.
 void setMax(java.lang.String m)
          Set the list maximum
 void setOffset(int o)
           
 void setOffset(java.lang.String o)
          Set the list offset
 void setOrderby(java.lang.String sorted)
          Sets the fields to sort on.
protected  int setReturnValues(NodeList nodes)
          Creates the node iterator and sets appropriate variables (i.e.
protected  int setReturnValues(NodeList nodes, boolean trim)
          Creates the node iterator and sets appropriate variables (i.e.
 int size()
           
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.AbstractNodeProviderTag
doEndTag, fillVars, getNodeVar, setFields, setJspvar, setNodeVar
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.CloudReferrerTag
findCloudProvider, getCloudContext, getCloudProviderVar, setCloud
 
Methods inherited from class org.mmbase.bridge.jsp.taglib.ContextReferrerTag
findParentTag, findParentTag, getAttributeValue, getContextTag, getContextTag, getReferid, getReferIdValue, release, setContext, setPageContext, setReferid, stringSplitter, stringSplitter
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
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.BodyTag
setBodyContent
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doEndTag, getParent, release, setPageContext, setParent
 
Methods inherited from interface org.mmbase.bridge.jsp.taglib.TagIdentifier
getId
 

Field Detail

sortedString

protected java.lang.String sortedString
Holds the list of fields to sort the list on. The sort itself is implementation specific.

directionString

protected java.lang.String directionString
Holds the direction to sort the list on (per field in sortedString). The sort itself is implementation specific.

whereString

protected java.lang.String whereString
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!).

max

protected int max
The maximum number of elements in a list. Setting the list size to conform to this maximum is implementation specific.

offset

protected int offset
The offset of the elements that are returned in a list. Setting the list to conform to this ofsset is implementation specific.

changed

protected boolean changed
Determines whether a field in sortedString changed during iteration.

returnValues

protected NodeIterator returnValues
Data member to hold an iterationof the values to return. This variable is set in setReturnValues(NodeList), which should be called from doStartTag(), and will be used to fill the return variables for every iteration.

listSize

protected int listSize
The actual size of the list.

currentItemIndex

protected int currentItemIndex
The current item
Constructor Detail

AbstractNodeListTag

public AbstractNodeListTag()
Method Detail

getIndex

public int getIndex()
Specified by:
getIndex in interface ListItemInfo
Following copied from interface: org.mmbase.bridge.jsp.taglib.ListItemInfo
Returns:
the index of the current item in a list

setOrderby

public void setOrderby(java.lang.String sorted)
                throws javax.servlet.jsp.JspTagException
Sets the fields to sort on.
Parameters:
sorted - A comma separated list of fields on witch the returned nodes should be sorted

setDirections

public void setDirections(java.lang.String directions)
                   throws javax.servlet.jsp.JspTagException
Sets the direction to sort on
Parameters:
direction - the selection query for the object we are looking for direction

setMax

public void setMax(java.lang.String m)
            throws javax.servlet.jsp.JspTagException
Set the list maximum
Parameters:
max - the max number of values returned

setMax

public void setMax(int m)
Sets the list maximum with an integer argument. Tomcat needs this if you feed it with an rtexprvalue of type int.

setOffset

public void setOffset(java.lang.String o)
               throws javax.servlet.jsp.JspTagException
Set the list offset
Parameters:
max - the max number of values returned

setOffset

public void setOffset(int o)

setConstraints

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

doStartTag

public abstract int doStartTag()
                        throws javax.servlet.jsp.JspTagException
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport

setReturnValues

protected int setReturnValues(NodeList nodes)
Creates the node iterator and sets appropriate variables (i.e. listsize) froma 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_TAG if the resulting list is not empty, SKIP_BODY if the list is empty. THis value should be passed as the result of {

setReturnValues

protected int setReturnValues(NodeList nodes,
                              boolean trim)
Creates the node iterator and sets appropriate variables (i.e. 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_TAG if the resulting list is not empty, SKIP_BODY if the list is empty. THis value should be passed as the result of {

doAfterBody

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

doInitBody

public void doInitBody()
                throws javax.servlet.jsp.JspTagException
Specified by:
doInitBody in interface javax.servlet.jsp.tagext.BodyTag
Overrides:
doInitBody in class AbstractNodeProviderTag

isFirst

public boolean isFirst()

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 ListItemInfo
Following copied from interface: org.mmbase.bridge.jsp.taglib.ListItemInfo
Returns:
a boolean indicating wether the field on which was sorted is changed.

size

public int size()
Specified by:
size in interface ListItemInfo
Following copied from interface: org.mmbase.bridge.jsp.taglib.ListItemInfo
Returns:
the size of the list

isLast

public boolean isLast()


MMBase 2001