/** * <p> Return the url encoded to maintain the user session, if any. </p> */ public String getEncodeURL(String url) { if ((session != null) && (response != null)) { boolean redirect = false; if (forward != null) { redirect = forward.getRedirect(); } if (redirect) { return response.encodeRedirectURL(url); } else { return response.encodeURL(url); } } else { return (url); } }
import org.apache.struts.action.ActionForward; public class ParameterizedForward extends ActionForward { public ParameterizedForward(ActionForward forward) { super(forward.getPath(), forward.getRedirect()); } public void addParameter(String key, String value) { StringBuffer sb = new StringBuffer(getPath()); if (key == null || key.length() < 1) return; if (getPath().indexOf('?') == -1) sb.append('?'); else sb.append('&'); sb.append(key + "=" + value); setPath(sb.toString()); } } ParameterizedForward fwd = new ParameterizedForward(mapping.findForward("success")); fwd.addParameter("name","jason"); fwd.addParameter("userLevel", "god"); return fwd;
/** * <p>Construct a new instance based on the values of another * ActionForward.</p> * * @param copyMe An ActionForward instance to copy * @since Struts 1.2.1 */ public ActionForward(ActionForward copyMe) { this(copyMe.getName(), copyMe.getPath(), copyMe.getRedirect(), copyMe.getModule()); } }
public MockActionForward(ActionForward copyMe) { setName(copyMe.getName()); setPath(copyMe.getPath()); setRedirect(copyMe.getRedirect()); try { Method getContextRelativeMethod = copyMe.getClass().getMethod("getContextRelative", null); Boolean value = (Boolean)getContextRelativeMethod.invoke(copyMe, null); if(null != value) { setContextRelative(value.booleanValue()); } } catch(Exception exc) { //Struts 1.3 does not define the method "getContextRelative" //this hack is necessary to avoid different versions for Struts 1.2 and 1.3 } }
public MockActionForward(ActionForward copyMe) { setName(copyMe.getName()); setPath(copyMe.getPath()); setRedirect(copyMe.getRedirect()); try { Method getContextRelativeMethod = copyMe.getClass().getMethod("getContextRelative", null); Boolean value = (Boolean)getContextRelativeMethod.invoke(copyMe, null); if(null != value) { setContextRelative(value.booleanValue()); } } catch(Exception exc) { //Struts 1.3 does not define the method "getContextRelative" //this hack is necessary to avoid different versions for Struts 1.2 and 1.3 } }
public MockActionForward(ActionForward copyMe) { setName(copyMe.getName()); setPath(copyMe.getPath()); setRedirect(copyMe.getRedirect()); try { Method getContextRelativeMethod = copyMe.getClass().getMethod("getContextRelative", null); Boolean value = (Boolean)getContextRelativeMethod.invoke(copyMe, null); if(null != value) { setContextRelative(value); } } catch(Exception exc) { //Struts 1.3 does not define the method "getContextRelative" //this hack is necessary to avoid different versions for Struts 1.2 and 1.3 } }
if ( returnForward!=null && returnForward.getRedirect() && returnForward.getName()!=null && returnForward.getName().equals(KRADConstants.KRAD_INITIATED_DOCUMENT_VIEW_NAME)) { return returnForward;
public void processFormActionAndForward(final HttpServletRequest request, final HttpServletResponse response, final ActionMapping mapping) throws ServletException, IOException { ActionForm form = processActionForm(request, response, mapping); processPopulate(request, response, form, mapping); // need to make sure that we don't check CSRF until after the form is populated so that Struts will parse the // multipart parameters into the request if it's a multipart request if (!getCsrfService().validateCsrfIfNecessary(request, response)) { return; } // Create or acquire the Action instance to process this request Action action = processActionCreate(request, response, mapping); if (action != null) { // Call the Action instance itself ActionForward forward = processActionPerform(request, response, action, form, mapping); if (forward != null) { if (forward.getRedirect() && forward.getName()!= null && forward.getName().equals(KRADConstants.KRAD_INITIATED_DOCUMENT_VIEW_NAME)) { LOG.info("Attempt to open a document with a status of \"Initiated\" detected"); return; } // ProcessDefinition the returned ActionForward instance processForwardConfig(request, response, forward); } } }
/** * Handles requests that originate via Header Tabs. * * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward headerTab(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // header tab actions can do two things - 1, call into an action and perform what needs to happen in there and 2, forward to // a new location. String headerTabDispatch = getHeaderTabDispatch(request); if (StringUtils.isNotEmpty(headerTabDispatch)) { ActionForward forward = dispatchMethod(mapping, form, request, response, headerTabDispatch); if (GlobalVariables.getMessageMap().getNumberOfPropertiesWithErrors() > 0) { return mapping.findForward(RiceConstants.MAPPING_BASIC); } this.doTabOpenOrClose(mapping, form, request, response, false); if (forward.getRedirect()) { return forward; } } return dispatchMethod(mapping, form, request, response, getHeaderTabNavigateTo(request)); }