1 19 20 package com.sslexplorer.wizard.forms; 21 22 import javax.servlet.http.HttpServletRequest ; 23 24 import org.apache.struts.action.ActionMapping; 25 26 import com.sslexplorer.core.forms.CoreForm; 27 import com.sslexplorer.security.Constants; 28 import com.sslexplorer.wizard.AbstractWizardSequence; 29 30 37 public abstract class AbstractWizardForm extends CoreForm { 38 39 private int gotoStep; 40 41 public AbstractWizardForm() { 42 super(); 43 } 44 45 52 public abstract void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception ; 53 54 57 public boolean isCommiting() { 58 return super.isCommiting() || "next".equals(getActionTarget()) || "gotoStep".equals(getActionTarget()) || 59 "finish".equals(getActionTarget()); 60 } 61 62 69 public abstract void apply(AbstractWizardSequence sequence) throws Exception ; 70 71 74 public void reset(ActionMapping mapping, HttpServletRequest request) { 75 super.reset(mapping, request); 76 setActionTarget("unspecified"); 77 } 78 79 84 public abstract boolean getNextAvailable(); 85 86 91 public abstract boolean getPreviousAvailable(); 92 93 98 public abstract boolean getFinishAvailable(); 99 100 108 public abstract String getPage(); 109 110 117 public abstract String getResourcePrefix(); 118 119 126 public abstract String getResourceBundle(); 127 128 133 public abstract int getStepIndex(); 134 135 141 public abstract String getPageName(); 142 143 148 public abstract String getFocussedField(); 149 150 155 public abstract boolean getAutocomplete(); 156 157 164 public String getNextOnClick() { 165 return "setActionTarget('next'); document.forms[0].submit(); return false"; 166 } 167 168 175 public String getPreviousOnClick() { 176 return "setActionTarget('previous'); document.forms[0].submit(); return false"; 177 } 178 179 186 public String getFinishOnClick() { 187 return "setActionTarget('finish'); document.forms[0].submit()"; 188 } 189 190 196 public String getFormEncoding() { 197 return "application/x-www-form-urlencoded"; 198 } 199 200 206 public String getFormAction() { 207 return "/" + getPageName() + ".do"; 208 } 209 210 217 public AbstractWizardSequence getWizardSequence(HttpServletRequest request) { 218 return (AbstractWizardSequence)request.getSession().getAttribute(Constants.WIZARD_SEQUENCE); 219 } 220 221 public int getGotoStep() { 222 return gotoStep; 223 } 224 225 public void setGotoStep(int gotoStep) { 226 this.gotoStep = gotoStep; 227 } 228 } 229 | Popular Tags |