Java Code Examples for org.apache.struts.action.ActionForward#setName()

The following examples show how to use org.apache.struts.action.ActionForward#setName() . 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: RefactoredIndividualCandidacyProcessPublicDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward forward(HttpServletRequest request, String windowLocation) {
    final ActionForward actionForward = new ActionForward();
    actionForward.setName(windowLocation);
    actionForward.setPath(windowLocation);
    actionForward.setRedirect(true);
    return actionForward;
}
 
Example 2
Source File: EditAddressAction.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/** {@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 3
Source File: EditAddressAction.java    From spacewalk with GNU General Public License v2.0 4 votes vote down vote up
/** {@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: StrutsDelegate.java    From uyuni with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 5
Source File: StrutsDelegate.java    From spacewalk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}