org.barracudamvc.core.comp
Class AbstractTemplateModel

java.lang.Object
  extended byorg.barracudamvc.core.comp.AbstractTemplateModel
All Implemented Interfaces:
Contextual, Model, TemplateModel
Direct Known Subclasses:
AbstractIterativeTemplateModel, DataObjectModel, DefaultPropertiesModel, GroupFormElement.ChildModel, HashMapModel, IterativeCollectionModel, IterativeListModel, ReflectionModel

public abstract class AbstractTemplateModel
extends Object
implements TemplateModel

This class provides the abstract implementation for a Template Model.


Field Summary
protected  List listeners
           
static String UNDEFINED
           
protected  ViewContext viewContext
           
 
Constructor Summary
AbstractTemplateModel()
           
 
Method Summary
 void addModelListener(ModelListener ml)
          Add a listener to the template that's notified each time a change to the data model occurs.
 void fireModelChanged()
          Forwards the given notification event to all TemplateModelListeners that registered themselves as listeners for this template model.
 Object getItem(String key)
          Convenience method to get an item based on the key name (extracted from the TemplateDirective).
 Object getItem(TemplateDirective td)
          get an item for a given template directive.
 ViewContext getViewContext()
          Get the current ViewContext
 boolean processDirective(TemplateDirective td)
          process any directives. return false to indicate a the node containing this directive should be skipped.
 void removeModelListener(ModelListener ml)
          Remove a listener
 void setViewContext(ViewContext ivc)
          Specify the ViewContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.barracudamvc.core.comp.TemplateModel
getName
 

Field Detail

UNDEFINED

public static final String UNDEFINED
See Also:
Constant Field Values

viewContext

protected ViewContext viewContext

listeners

protected List listeners
Constructor Detail

AbstractTemplateModel

public AbstractTemplateModel()
Method Detail

addModelListener

public void addModelListener(ModelListener ml)
Add a listener to the template that's notified each time a change to the data model occurs.

Specified by:
addModelListener in interface Model
Parameters:
ml - the TemplateModelListener

removeModelListener

public void removeModelListener(ModelListener ml)
Remove a listener

Specified by:
removeModelListener in interface Model
Parameters:
ml - the TemplateModelListener

fireModelChanged

public void fireModelChanged()
Forwards the given notification event to all TemplateModelListeners that registered themselves as listeners for this template model.


processDirective

public boolean processDirective(TemplateDirective td)
process any directives. return false to indicate a the node containing this directive should be skipped.

Specified by:
processDirective in interface TemplateModel

getItem

public Object getItem(TemplateDirective td)
get an item for a given template directive. Implement this method if you want access to the full directive, not just the String key. Note that if you implement this method, AND you want to use the getItem(String key) method, then your implementation of this method must be sure to call super.getItem() in order for for the convenience method to get called.

Specified by:
getItem in interface TemplateModel

getItem

public Object getItem(String key)
Convenience method to get an item based on the key name (extracted from the TemplateDirective).


setViewContext

public void setViewContext(ViewContext ivc)
Specify the ViewContext. This method will generally be called by the class that is using the model to actually render the data in a view. The context will be specified prior to a render pass, and the context will be reset to null after the render pass.

Specified by:
setViewContext in interface Contextual
Parameters:
ivc - the current ViewContext

getViewContext

public ViewContext getViewContext()
Get the current ViewContext

Specified by:
getViewContext in interface Contextual
Returns:
the current ViewContext


Copyright © 2004 BarracudaMVC.org All Rights Reserved.