Java Code Examples for org.apache.struts.action.ActionForward#getRedirect()
The following examples show how to use
org.apache.struts.action.ActionForward#getRedirect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KualiRequestProcessor.java From rice with Educational Community License v2.0 | 6 votes |
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); // 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); } } }
Example 2
Source File: KualiAction.java From rice with Educational Community License v2.0 | 6 votes |
/** * 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)); }
Example 3
Source File: EditAddressAction.java From uyuni with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { DynaActionForm form = (DynaActionForm)formIn; /* Validate the form. We don't do this on satellite since none of * the fields are required */ ActionErrors verrors = RhnValidationHelper.validateDynaActionForm(this, form); if (!verrors.isEmpty()) { RhnValidationHelper.setFailedValidation(request); addErrors(request, verrors); return mapping.findForward("failure"); } RequestContext requestContext = new RequestContext(request); User targetUser = UserManager.lookupUser(requestContext.getCurrentUser(), requestContext.getParamAsLong("uid")); request.setAttribute(RhnHelper.TARGET_USER, targetUser); if (targetUser == null) { LocalizationService ls = LocalizationService.getInstance(); LookupException e = new LookupException("Could not find user"); e.setLocalizedTitle(ls.getMessage("lookup.jsp.title.user")); e.setLocalizedReason1(ls.getMessage("lookup.jsp.reason1.user")); e.setLocalizedReason2(ls.getMessage("lookup.jsp.reason2.user")); throw e; } String addrType = (String) form.get("type"); if (addrType == null) { throw new IllegalArgumentException("Invalid type"); } targetUser.setPhone((String) form.get("phone")); targetUser.setFax((String) form.get("fax")); targetUser.setAddress1((String) form.get("address1")); targetUser.setAddress2((String) form.get("address2")); targetUser.setCity((String) form.get("city")); targetUser.setState((String) form.get("state")); targetUser.setZip((String) form.get("zip")); targetUser.setCountry((String) form.get("country")); UserManager.storeUser(targetUser); ActionForward base = mapping.findForward("success"); Map<String, Object> params = new HashMap<String, Object>(); params.put("uid", String.valueOf(targetUser.getId())); params.put("type", addrType); String newPath = ServletUtils.pathWithParams(base.getPath(), params); ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.addressChanged")); getStrutsDelegate().saveMessages(request, msgs); ActionForward fwd = new ActionForward(newPath, base.getRedirect()); fwd.setName("success"); return fwd; }
Example 4
Source File: KualiAction.java From rice with Educational Community License v2.0 | 4 votes |
/** * Entry point to all actions. * * NOTE: No need to hook into execute for handling framework setup anymore. Just implement the methodToCall for the framework * setup, Constants.METHOD_REQUEST_PARAMETER will contain the full parameter, which can be sub stringed for getting framework * parameters. * * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward returnForward = null; String methodToCall = findMethodToCall(form, request); if(isModuleLocked(form, methodToCall, request)) { return mapping.findForward(RiceConstants.MODULE_LOCKED_MAPPING); } if (form instanceof KualiForm && StringUtils.isNotEmpty(((KualiForm) form).getMethodToCall())) { if (StringUtils.isNotBlank(getImageContext(request, KRADConstants.ANCHOR))) { ((KualiForm) form).setAnchor(getImageContext(request, KRADConstants.ANCHOR)); } else if (StringUtils.isNotBlank(request.getParameter(KRADConstants.ANCHOR))) { ((KualiForm) form).setAnchor(request.getParameter(KRADConstants.ANCHOR)); } else { ((KualiForm) form).setAnchor(KRADConstants.ANCHOR_TOP_OF_FORM); } } // if found methodToCall, pass control to that method, else return the basic forward if (StringUtils.isNotBlank(methodToCall)) { if ( LOG.isDebugEnabled() ) { LOG.debug("methodToCall: '" + methodToCall+"'"); } returnForward = dispatchMethod(mapping, form, request, response, methodToCall); if ( returnForward!=null && returnForward.getRedirect() && returnForward.getName()!=null && returnForward.getName().equals(KRADConstants.KRAD_INITIATED_DOCUMENT_VIEW_NAME)) { return returnForward; } } else { returnForward = defaultDispatch(mapping, form, request, response); } // make sure the user can do what they're trying to according to the module that owns the functionality if ( !methodToCallsToNotCheckAuthorization.contains(methodToCall) ) { if ( LOG.isDebugEnabled() ) { LOG.debug( "'" + methodToCall + "' not in set of excempt methods: " + methodToCallsToNotCheckAuthorization); } checkAuthorization(form, methodToCall); } else { if ( LOG.isDebugEnabled() ) { LOG.debug("'" + methodToCall + "' is exempt from auth checks." ); } } // Add the ActionForm to GlobalVariables // This will allow developers to retrieve both the Document and any request parameters that are not // part of the Form and make them available in ValueFinder classes and other places where they are needed. if(KNSGlobalVariables.getKualiForm() == null) { KNSGlobalVariables.setKualiForm((KualiForm)form); } return returnForward; }
Example 5
Source File: EditAddressAction.java From spacewalk with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { DynaActionForm form = (DynaActionForm)formIn; /* Validate the form. We don't do this on satellite since none of * the fields are required */ ActionErrors verrors = RhnValidationHelper.validateDynaActionForm(this, form); if (!verrors.isEmpty()) { RhnValidationHelper.setFailedValidation(request); addErrors(request, verrors); return mapping.findForward("failure"); } RequestContext requestContext = new RequestContext(request); User targetUser = UserManager.lookupUser(requestContext.getCurrentUser(), requestContext.getParamAsLong("uid")); request.setAttribute(RhnHelper.TARGET_USER, targetUser); if (targetUser == null) { LocalizationService ls = LocalizationService.getInstance(); LookupException e = new LookupException("Could not find user"); e.setLocalizedTitle(ls.getMessage("lookup.jsp.title.user")); e.setLocalizedReason1(ls.getMessage("lookup.jsp.reason1.user")); e.setLocalizedReason2(ls.getMessage("lookup.jsp.reason2.user")); throw e; } String addrType = (String) form.get("type"); if (addrType == null) { throw new IllegalArgumentException("Invalid type"); } targetUser.setPhone((String) form.get("phone")); targetUser.setFax((String) form.get("fax")); targetUser.setAddress1((String) form.get("address1")); targetUser.setAddress2((String) form.get("address2")); targetUser.setCity((String) form.get("city")); targetUser.setState((String) form.get("state")); targetUser.setZip((String) form.get("zip")); targetUser.setCountry((String) form.get("country")); UserManager.storeUser(targetUser); ActionForward base = mapping.findForward("success"); Map<String, Object> params = new HashMap<String, Object>(); params.put("uid", String.valueOf(targetUser.getId())); params.put("type", addrType); String newPath = ServletUtils.pathWithParams(base.getPath(), params); ActionMessages msgs = new ActionMessages(); msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.addressChanged")); getStrutsDelegate().saveMessages(request, msgs); ActionForward fwd = new ActionForward(newPath, base.getRedirect()); fwd.setName("success"); return fwd; }
Example 6
Source File: StrutsDelegate.java From uyuni with GNU General Public License v2.0 | 3 votes |
/** * Take an action forward and toss on a set of form variables. * * @param base Base ActionForward * * @param params Parameters to be added to the ActionForward url. * * @return a new ActionForward with the path of the base appended with the * param and value. */ public ActionForward forwardParams(ActionForward base, Map params) { Asserts.assertNotNull(base, "base"); String newPath = ServletUtils.pathWithParams(base.getPath(), params); ActionForward af = new ActionForward(newPath, base.getRedirect()); af.setName(base.getName()); return af; }
Example 7
Source File: StrutsDelegate.java From spacewalk with GNU General Public License v2.0 | 3 votes |
/** * Take an action forward and toss on a set of form variables. * * @param base Base ActionForward * * @param params Parameters to be added to the ActionForward url. * * @return a new ActionForward with the path of the base appended with the * param and value. */ public ActionForward forwardParams(ActionForward base, Map params) { Asserts.assertNotNull(base, "base"); String newPath = ServletUtils.pathWithParams(base.getPath(), params); ActionForward af = new ActionForward(newPath, base.getRedirect()); af.setName(base.getName()); return af; }