org.barracudamvc.core.comp
Class AbstractBlockIterator

java.lang.Object
  extended by org.barracudamvc.core.comp.AbstractBlockIterator
All Implemented Interfaces:
BlockIterator

public abstract class AbstractBlockIterator
extends Object
implements BlockIterator

This class provides the abstract implementation of a BlockIterator. Basically, it will


Field Summary
protected  String name
           
protected  BTemplate templateComp
           
protected  Object templateModels
           
 
Fields inherited from interface org.barracudamvc.core.comp.BlockIterator
BLOCK_ITERATOR_CONTEXT
 
Constructor Summary
AbstractBlockIterator()
           
 
Method Summary
 String getName()
          Get the block iterator name (from the block iterator template directive)
abstract  Object getTemplateModels()
          Provide the template models which back this iterator.
abstract  boolean hasNext()
          Allows the developer to return true if there are more rows to be processed
 void invalidateTemplateModels()
          Clear the current template models (which will cause the component to be repopulated using getTemplateModels()
abstract  boolean loadNext()
          Actually allows developer to increment forward in the data layer.
 Node next(ViewContext vc, Node templateNode)
          Asks the developer to process a node (given the current data layer context)
 void postIterate()
          Gets called after iteration is complete.
 void preIterate()
          Gets called prior to iteration.
 void setName(String iname)
          Set the block iterator name (from the block iterator template directive)
 void updateTemplateModels(Object itemplateModels)
          Provide a method to immeditately force an update on the model(s) that back this iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

templateModels

protected Object templateModels

templateComp

protected BTemplate templateComp

name

protected String name
Constructor Detail

AbstractBlockIterator

public AbstractBlockIterator()
Method Detail

setName

public void setName(String iname)
Set the block iterator name (from the block iterator template directive)

Specified by:
setName in interface BlockIterator

getName

public String getName()
Get the block iterator name (from the block iterator template directive)

Specified by:
getName in interface BlockIterator

preIterate

public void preIterate()
Gets called prior to iteration. If you override this method, its always good practice to call super.preIterate() just to be safe.

Specified by:
preIterate in interface BlockIterator

hasNext

public abstract boolean hasNext()
Allows the developer to return true if there are more rows to be processed

Specified by:
hasNext in interface BlockIterator

loadNext

public abstract boolean loadNext()
Actually allows developer to increment forward in the data layer. Returning false here just means 'skip this particular iteration'

Specified by:
loadNext in interface BlockIterator

next

public Node next(ViewContext vc,
                 Node templateNode)
          throws RenderException
Asks the developer to process a node (given the current data layer context)

Specified by:
next in interface BlockIterator
Throws:
RenderException

getTemplateModels

public abstract Object getTemplateModels()
Provide the template models which back this iterator. This may be an individual TemplateModel, or a List of such models. By default, this method is only called ONCE for the entire iteration (ie. models reused across each item in the iteration). If you want to update the models as you go, you need to either call invalidateModels() or updateModel(TemplateModel) (and the best place to do this is in the loadNext() method)

Specified by:
getTemplateModels in interface BlockIterator

postIterate

public void postIterate()
Gets called after iteration is complete. If you override this method, you MUST call super.postIterate() to allow the parent class a chance to perform cleanup

Specified by:
postIterate in interface BlockIterator

invalidateTemplateModels

public void invalidateTemplateModels()
Clear the current template models (which will cause the component to be repopulated using getTemplateModels()

Specified by:
invalidateTemplateModels in interface BlockIterator

updateTemplateModels

public void updateTemplateModels(Object itemplateModels)
Provide a method to immeditately force an update on the model(s) that back this iterator. The object passed may either be a single TemplateModel or a List of such models.

Specified by:
updateTemplateModels in interface BlockIterator


Copyright © 2006 BarracudaMVC.org All Rights Reserved.