1 23 24 package com.sun.enterprise.tools.guiframework.model; 25 26 import com.iplanet.jato.ModelTypeMap; 27 import com.iplanet.jato.RequestContext; 28 import com.iplanet.jato.model.DefaultModel; 29 import com.iplanet.jato.model.Model; 30 31 import java.util.HashMap ; 32 import java.util.Map ; 33 34 35 42 public class ModelManager extends com.iplanet.jato.ModelManager { 43 44 55 public ModelManager(RequestContext requestContext, ModelTypeMap typeMap) { 56 super(requestContext, typeMap); 57 } 58 59 60 66 public Model getModel(Class cls, String name, boolean lookInSession, boolean storeInSession) { 67 Model model = (Model)getInstanceMap().get(name); 69 if (model != null) { 70 return model; 71 } 72 73 model = super.getModel(cls, name, lookInSession, storeInSession); 75 76 if (model != null) { 78 if (model instanceof DefaultModel) { 79 ((DefaultModel)model).setUseDefaultValues(false); 81 } 82 getInstanceMap().put(name, model); 83 } 84 85 return model; 87 } 88 89 90 102 public void registerModel(String name, Model model) { 103 if (name == null) { 104 throw new IllegalArgumentException ( 105 "You cannot register a Model with a (null) name!"); 106 } 107 getInstanceMap().put(name, model); 108 } 109 110 111 114 public boolean contains(String name) { 115 return getInstanceMap().containsKey(name); 116 } 117 118 119 122 protected Map getInstanceMap() { 123 return _instanceMap; 124 } 125 126 127 130 protected void setInstanceMap(Map map) { 131 _instanceMap = map; 132 } 133 134 135 private Map _instanceMap = new HashMap (); 136 } 137 | Popular Tags |