1 7 package com.inversoft.verge.mvc.controller.actionflow; 8 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 import javax.servlet.ServletRequest ; 14 15 import com.inversoft.verge.mvc.MVCException; 16 import com.inversoft.verge.mvc.config.BaseFormConfig; 17 import com.inversoft.verge.mvc.config.BaseFormConfigMetaData; 18 import com.inversoft.verge.mvc.controller.actionflow.config.ActionFlowConfigRegistry; 19 import com.inversoft.verge.mvc.controller.actionflow.config.Namespace; 20 21 22 32 public class ActionFlowMetaData extends BaseFormConfigMetaData { 33 34 private String entry; 35 private String action; 36 private String namespace; 37 private boolean modelEnabled = true; 38 private boolean validationEnabled = true; 39 40 41 44 ActionFlowMetaData() { 45 } 46 47 53 public ActionFlowMetaData(String namespace, String form) { 54 this(namespace, form, null, null, null); 55 } 56 57 66 public ActionFlowMetaData(String namespace, String form, String entry, 67 String action, Map extraParams) { 68 super(form); 69 assert (namespace != null) : "namespace parameter missing"; 70 71 this.entry = entry; 72 this.action = action; 73 this.namespace = namespace; 74 75 if (extraParams != null) { 76 String meStr = 77 (String ) extraParams.get(ActionFlowURLTools.MODEL_ENABLED_PARAM); 78 if (meStr != null) { 79 this.modelEnabled = Boolean.valueOf(meStr).booleanValue(); 80 } 81 82 String veStr = 83 (String ) extraParams.get(ActionFlowURLTools.VALIDATION_ENABLED_PARAM); 84 if (veStr != null) { 85 this.validationEnabled = Boolean.valueOf(veStr).booleanValue(); 86 } 87 } 88 } 89 90 91 96 public String getEntry() { 97 return entry; 98 } 99 100 105 public void setEntry(String entry) { 106 this.entry = entry; 107 } 108 109 114 public String getAction() { 115 return action; 116 } 117 118 123 public void setAction(String action) { 124 this.action = action; 125 } 126 127 132 public String getNamespace() { 133 return namespace; 134 } 135 136 141 public void setNamespace(String namespace) { 142 this.namespace = namespace; 143 } 144 145 150 public void setForm(String form) { 151 this.form = form; 152 } 153 154 159 public boolean isModelEnabled() { 160 return modelEnabled; 161 } 162 163 168 public void setModelEnabled(boolean modelEnabled) { 169 this.modelEnabled = modelEnabled; 170 } 171 172 177 public boolean isValidationEnabled() { 178 return validationEnabled; 179 } 180 181 186 public void setValidationEnabled(boolean validationEnabled) { 187 this.validationEnabled = validationEnabled; 188 } 189 190 196 public Map getExtraParams() { 197 Map map = new HashMap (); 198 199 if (!modelEnabled) { 200 map.put(ActionFlowURLTools.MODEL_ENABLED_PARAM, 201 new Boolean (modelEnabled)); 202 } 203 204 if (!validationEnabled) { 205 map.put(ActionFlowURLTools.VALIDATION_ENABLED_PARAM, 206 new Boolean (validationEnabled)); 207 } 208 209 return map; 210 } 211 212 219 public BaseFormConfig findFormConfig(ServletRequest request) 220 throws MVCException { 221 222 Namespace namespace = 223 ActionFlowConfigRegistry.getInstance(request).lookup(this.namespace); 224 if (namespace == null) { 225 throw new MVCException("Invalid namespace named: " + this.namespace + 226 " for form named: " + getForm()); 227 } 228 229 BaseFormConfig form = namespace.lookupForm(getForm()); 230 if (form == null) { 231 throw new MVCException("Form named: " + getForm() + " not found"); 232 } 233 234 return form; 235 } 236 } | Popular Tags |