1 16 17 package org.apache.struts.chain; 18 19 20 import org.apache.commons.chain.Command; 21 import org.apache.commons.chain.Context; 22 import org.apache.struts.chain.Constants; 23 import org.apache.struts.action.Action; 24 import org.apache.struts.action.ActionForm; 25 import org.apache.struts.config.ActionConfig; 26 import org.apache.struts.config.ForwardConfig; 27 28 29 36 37 public abstract class AbstractExecuteAction implements Command { 38 39 40 42 43 private String actionKey = Constants.ACTION_KEY; 44 private String actionConfigKey = Constants.ACTION_CONFIG_KEY; 45 private String actionFormKey = Constants.ACTION_FORM_KEY; 46 private String forwardConfigKey = Constants.FORWARD_CONFIG_KEY; 47 private String validKey = Constants.VALID_KEY; 48 49 50 52 53 58 public String getActionKey() { 59 60 return (this.actionKey); 61 62 } 63 64 65 72 public void setActionKey(String actionKey) { 73 74 this.actionKey = actionKey; 75 76 } 77 78 79 84 public String getActionConfigKey() { 85 86 return (this.actionConfigKey); 87 88 } 89 90 91 98 public void setActionConfigKey(String actionConfigKey) { 99 100 this.actionConfigKey = actionConfigKey; 101 102 } 103 104 105 110 public String getActionFormKey() { 111 112 return (this.actionFormKey); 113 114 } 115 116 117 124 public void setActionFormKey(String actionFormKey) { 125 126 this.actionFormKey = actionFormKey; 127 128 } 129 130 131 136 public String getForwardConfigKey() { 137 138 return (this.forwardConfigKey); 139 140 } 141 142 143 150 public void setForwardConfigKey(String forwardConfigKey) { 151 152 this.forwardConfigKey = forwardConfigKey; 153 154 } 155 156 157 161 public String getValidKey() { 162 163 return (this.validKey); 164 165 } 166 167 168 174 public void setValidKey(String validKey) { 175 176 this.validKey = validKey; 177 178 } 179 180 181 183 184 195 public boolean execute(Context context) throws Exception { 196 197 Boolean valid = (Boolean ) context.get(getValidKey()); 199 if ((valid == null) || !valid.booleanValue()) { 200 return (false); 201 } 202 203 Action action = (Action) 205 context.get(getActionKey()); 206 if (action == null) { 207 return (false); 208 } 209 ActionConfig actionConfig = (ActionConfig) 210 context.get(getActionConfigKey()); 211 ActionForm actionForm = (ActionForm) 212 context.get(getActionFormKey()); 213 214 ForwardConfig forwardConfig = 216 execute(context, action, actionConfig, actionForm); 217 context.put(getForwardConfigKey(), forwardConfig); 218 219 return (false); 220 221 } 222 223 224 226 227 239 protected abstract ForwardConfig execute(Context context, 240 Action action, 241 ActionConfig actionConfig, 242 ActionForm actionForm) 243 throws Exception ; 244 245 246 } 247 | Popular Tags |