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

The following examples show how to use org.apache.struts.action.ActionForward#setRedirect() . 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: UserLocalePrefAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
private ActionForward save(ActionMapping mapping, RequestContext ctx,
            User currentUser, DynaActionForm form) {
    String preferredLocale = form.getString("preferredLocale");
    if (preferredLocale != null && preferredLocale.equals("none")) {
        preferredLocale = null;
    }
    currentUser.setTimeZone(UserManager.getTimeZone(
            ((Integer) form.get("timezone")).intValue()));
    currentUser.setPreferredLocale(preferredLocale);
    UserManager.storeUser(currentUser);
    ActionMessages msgs = new ActionMessages();
    msgs.add(ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("message.preferencesModified"));
    getStrutsDelegate().saveMessages(ctx.getRequest(), msgs);
    if (ctx.getRequest().getParameter("uid") != null) {
        ActionForward display = mapping.findForward("display");
        ActionForward fwd = new ActionForward();
        fwd.setPath(display.getPath() + "?uid=" + currentUser.getId());
        fwd.setRedirect(true);
        return fwd;
    }
    return mapping.findForward("display");
}
 
Example 2
Source File: NotAllowedActionExceptionHandler.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ActionForward execute(Exception ex, 
           ExceptionConfig exConfig,
           ActionMapping mapping,
           ActionForm formInstance,
           HttpServletRequest request,
           HttpServletResponse response
	) throws ServletException {

       ActionForward actionForward = new ActionForward();
       actionForward.setPath(exConfig.getPath());
       actionForward.setRedirect(true);
       return actionForward;
}
 
Example 3
Source File: FenixDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward forwardForDestination(ViewDestination destination) {
    ActionForward forward = new ActionForward();
    forward.setModule(destination.getModule());
    forward.setPath(destination.getPath());
    forward.setRedirect(destination.getRedirect());
    return forward;
}
 
Example 4
Source File: EditMissingCandidacyInformationDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {

        final PersonalInformationBean personalInformationBean = getRenderedObject("personalInformationBean");

        final Set<String> messages = personalInformationBean.validate();

        if (!messages.isEmpty()) {
            for (final String each : messages) {
                addActionMessage(request, each);
            }
            return prepareEditInvalid(mapping, form, request, response);
        }

        try {
            personalInformationBean.updatePersonalInformation(true);
        } catch (DomainException e) {
            addActionMessage(request, e.getKey(), e.getArgs());
            return prepareEditInvalid(mapping, form, request, response);
        }

        if (personalInformationBean.getStudent().hasAnyMissingPersonalInformation()) {
            RenderUtils.invalidateViewState();
            return prepareEdit(mapping, form, request, response);
        }

        final ActionForward forward = new ActionForward();
        forward.setPath("/home.do");
        forward.setRedirect(true);
        forward.setModule("/");

        return forward;

    }
 
Example 5
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 6
Source File: StudentEnrolmentsDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ActionForward editEnrolment(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                                          final HttpServletResponse response) {

    final EditEnrolmentBean enrolmentBean = getRenderedObject();
    final Enrolment enrolment = enrolmentBean.getEnrolment();

    final Double newWeight = enrolmentBean.getWeight();
    final EctsConversionTable newEctsConversionTable = enrolmentBean.getEctsConversionTable();
    final Grade newNormalizedGrade = enrolmentBean.getNormalizedGrade();

    Double oldWeight = enrolment.getWeigth();

    RenderUtils.invalidateViewState();
    
    FenixFramework.atomic(() -> {
        if (newEctsConversionTable instanceof EmptyConversionTable) {
            if (newNormalizedGrade.isEmpty()) {
                // use default table
                enrolment.setEctsConversionTable(null);
                enrolment.setEctsGrade(null);
            } else {
                enrolment.setEctsGrade(newNormalizedGrade);
                enrolment.setEctsConversionTable(newEctsConversionTable);
            }
        } else {
            // default to the selected table
            enrolment.setEctsGrade(null);
            enrolment.setEctsConversionTable(newEctsConversionTable);
        }

        enrolment.setWeigth(newWeight);
    });

    LOGGER.info("Changed enrolment {} of student {} by user {}", enrolmentBean.getEnrolment().getExternalId(),
                enrolmentBean.getEnrolment().getStudent().getPerson().getUsername(), Authenticate.getUser().getUsername());
    LOGGER.info("\t newEctsConversionTable: {}", newEctsConversionTable == null ? "-" : newEctsConversionTable
                                                                                            .getPresentationName().getContent());
    LOGGER.info("\t newEctsGrade: {}", newNormalizedGrade == null ? "-" : newNormalizedGrade.getValue());
    if (!oldWeight.equals(newWeight)) {
        LOGGER.info("\t oldWeight: {} newWeight: {}", oldWeight.toString(), newWeight.toString());
    }


    final UriBuilder builder = UriBuilder.fromPath("/academicAdministration/studentEnrolments.do");
    builder.queryParam("method", "prepare");
    final String scpID = request.getParameter("scpID");
    final String executionPeriodId = request.getParameter("executionPeriodId");

    if (!Strings.isNullOrEmpty(scpID)) {
        builder.queryParam("scpID", scpID);
    }

    if (!Strings.isNullOrEmpty(executionPeriodId)) {
        builder.queryParam("executionPeriodId", executionPeriodId);
    }

    final String redirectTo = GenericChecksumRewriter.injectChecksumInUrl(request.getContextPath(), builder.toString(), request.getSession(false));
    
    final ActionForward actionForward = new ActionForward();
    actionForward.setModule("/");
    actionForward.setPath(redirectTo);
    actionForward.setRedirect(true);

    return actionForward;
}