1 20 package org.enhydra.barracuda.core.comp; 21 22 import java.util.*; 23 import org.enhydra.barracuda.core.comp.model.*; 24 25 29 public abstract class AbstractTemplateModel implements TemplateModel { 30 31 public static final String UNDEFINED = "Undefined"; 32 33 protected ViewContext viewContext = null; 34 protected List listeners = new ArrayList(); 35 36 43 public void addModelListener(ModelListener ml) { 44 listeners.add(ml); 45 } 46 47 52 public void removeModelListener(ModelListener ml) { 53 listeners.remove(ml); 54 } 55 56 61 public void fireModelChanged() { 62 Iterator it = listeners.iterator(); 63 ModelListener ml = null; 64 while (it.hasNext()) { 65 ml = (ModelListener) it.next(); 66 ml.modelChanged(this); 67 } 68 } 69 70 71 78 82 87 91 98 104 108 public boolean processDirective(TemplateDirective td) { 109 return true; } 111 112 121 public Object getItem(TemplateDirective td) { 122 return getItem(td.getKeyName()); 123 } 124 125 129 public Object getItem(String key) { 130 return getName()+"."+key+" "+UNDEFINED; 131 } 132 133 143 152 158 162 171 public void setViewContext(ViewContext ivc) { 172 viewContext = ivc; 173 } 174 175 180 public ViewContext getViewContext() { 181 return viewContext; 182 } 183 184 } | Popular Tags |