1 23 24 package org.infoglue.cms.applications.common.actions; 25 26 import org.infoglue.cms.exception.ConfigurationError; 27 28 import webwork.util.ServletValueStack; 29 30 31 39 public class ConfirmRedirect extends InfoGlueAbstractAction { 40 41 private static final long serialVersionUID = 8512298644737456785L; 42 43 private String unparsedURL; 44 45 46 public void setUrl(String unparsedURL) 47 { 48 this.unparsedURL = unparsedURL; 49 } 50 51 public String doExecute() throws Exception 52 { 53 validateUnparsedURL(); 54 redirect(); 55 return SUCCESS; 56 } 57 58 59 private void validateUnparsedURL() 60 { 61 if (this.unparsedURL == null || this.unparsedURL.trim().length() == 0) 62 { 63 throw new ConfigurationError("No url/empty url specified for ExtendedRedirect.action"); 64 } 65 } 66 67 68 69 private void redirect() throws Exception 70 { 71 final String url = getValueFromCallingAction(this.unparsedURL); 72 getResponse().sendRedirect(url); 73 } 74 75 76 private String getValueFromCallingAction(String fieldName) 77 { 78 Object value = ServletValueStack.getStack(getRequest()).findValue(fieldName); 79 81 if (value==null) 82 value = getRequest().getParameter(fieldName); 83 84 if (value == null) 85 { 86 throw new ConfigurationError("Unable to find the value for the parameter [" + fieldName + "]."); 87 } 88 89 90 return value.toString(); 91 } 92 93 94 } 95 | Popular Tags |