Java Code Examples for org.apache.struts.action.ActionMapping#getInputForward()

The following examples show how to use org.apache.struts.action.ActionMapping#getInputForward() . 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: MailingWizardAction.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * If the user is not logged in - forwards to login page.<br>
    * Saves existing textmodule.<br>
    * Calls method <code>textmodule</code> of this class. Sets dynName property of form. Updates property that
    * indicates if we need to show HTML editor for editing content. Loads target groups list into request. Forwards to
    * textmodule editing page.
    *
    * @param mapping The ActionMapping used to select this instance
    * @param form data for the action filled by the jsp
    * @param req request from jsp
    * @param res response
    * @return destination specified in struts-config.xml to forward to next jsp
    * @throws Exception if a exception occurs
    */
public ActionForward textmodule_save(ActionMapping mapping, ActionForm form,
		HttpServletRequest req, HttpServletResponse res) throws Exception {

	if (!AgnUtils.isUserLoggedIn(req)) {
		return mapping.findForward("logon");
	}
       MailingWizardForm aForm = (MailingWizardForm) form;
       String dynName = aForm.getDynName();
       Mailing mailing = aForm.getMailing();
       textmodule(mapping, form, req, res);
       aForm.setDynName(dynName);
       aForm.setShowHTMLEditorForDynTag(allowHTMLEditor(mailing, dynName));
       prepareAttachmentPage(req);
       return mapping.getInputForward();
}
 
Example 2
Source File: ManageClassesDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward deleteClasses(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    DynaActionForm deleteClassesForm = (DynaActionForm) form;
    String[] selectedClasses = (String[]) deleteClassesForm.get("selectedItems");

    if (selectedClasses.length == 0) {
        ActionErrors actionErrors = new ActionErrors();
        actionErrors.add("errors.classes.notSelected", new ActionError("errors.classes.notSelected"));
        saveErrors(request, actionErrors);
        return mapping.getInputForward();

    }
    List<String> classOIDs = new ArrayList<String>();
    for (String selectedClasse : selectedClasses) {
        classOIDs.add(selectedClasse);
    }

    DeleteClasses.run(classOIDs);

    return listClasses(mapping, form, request, response);

}
 
Example 3
Source File: ComMailingWizardAction.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
public ActionForward addTarget(ActionMapping mapping, ActionForm form,
                               HttpServletRequest request, HttpServletResponse response){
    if (!AgnUtils.isUserLoggedIn(request)) {
        return mapping.findForward("logon");
    }
    MailingWizardForm aForm = (MailingWizardForm) form;
    Mailing mailing = aForm.getMailing();
    request.setAttribute("isEnableTrackingVeto", configService.getBooleanValue(ConfigValue.EnableTrackingVeto, AgnUtils.getCompanyID(request)));

    MediatypeEmail param = mailing.getEmailParam();
    param.setOnepixel(aForm.getEmailOnepixel());
    prepareTargetPage(request);
    

    Collection<Integer> targetGroups = mailing.getTargetGroups();

    if (targetGroups == null) {
        targetGroups = new HashSet<>();
        mailing.setTargetGroups(targetGroups);
    }
    ComTarget aTarget = targetDao.getTarget(aForm.getTargetID(), AgnUtils.getCompanyID(request));
    if (!targetGroups.contains(aForm.getTargetID()) && aTarget != null && aTarget.getDeleted() == 0) {
        targetGroups.add(aForm.getTargetID());
    }
    return mapping.getInputForward();
}
 
Example 4
Source File: FenixDomainExceptionHandler.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ActionForward execute(Exception ex, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) throws ServletException {

    ActionForward forward = mapping.getInputForward();

    if (ex instanceof DomainException) {
        super.execute(ex, exceptionConfig, mapping, actionForm, request, response);

        DomainException domainException = (DomainException) ex;
        String property = domainException.getKey();
        ActionMessage error = new ActionMessage(domainException.getKey(), domainException.getArgs());
        super.storeException(request, property, error, forward, exceptionConfig.getScope());
    }
    return forward;
}
 
Example 5
Source File: MarkSheetSearchDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
private ActionForward searchMarkSheets(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response, MarkSheetManagementSearchBean searchBean) throws FenixServiceException {

    ActionMessages actionMessages = createActionMessages();
    try {
        Map<EvaluationSeason, MarkSheetSearchResultBean> result = SearchMarkSheets.run(searchBean);

        request.setAttribute("edit", searchBean);
        request.setAttribute("searchResult", result);
        request.setAttribute("url", buildSearchUrl(searchBean));

    } catch (InvalidArgumentsServiceException e) {
        addMessage(request, actionMessages, e.getMessage());
    }
    return mapping.getInputForward();
}
 
Example 6
Source File: ExecutionDegreesManagementDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward readCoordinators(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) {

    final DynaActionForm form = (DynaActionForm) actionForm;
    final String executionDegreeID = (String) form.get("executionDegreeID");
    if (!StringUtils.isEmpty(executionDegreeID)) {
        final ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeID);

        request.setAttribute("executionDegree", executionDegree);
        setResponsibleCoordinatorsIDs(executionDegree, form);
        return mapping.findForward("manageCoordinators");

    } else {
        return mapping.getInputForward();
    }
}
 
Example 7
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward prepareShiftEnrollment(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    final Registration registration = getAndSetRegistration(request);
    if (registration == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final String classID = request.getParameter("classId");
    if (classID != null) {
        request.setAttribute("classId", classID);
        return mapping.findForward("showEnrollmentPage");
    }

    final ExecutionSemester executionSemester = ExecutionSemester.readActualExecutionSemester();
    if (readAndSetSelectCoursesParameter(request) == null) {
        return prepareShiftEnrolmentInformation(mapping, request, registration, executionSemester);
    } else {
        return prepareSelectCoursesInformation(mapping, actionForm, request, registration, executionSemester);
    }
}
 
Example 8
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward prepareStartViewWarning(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {

    String executionSemesterID = (String) getFromRequest(request, "executionSemesterID");
    if (!StringUtils.isEmpty(executionSemesterID)) {
        request.setAttribute("executionSemesterID", executionSemesterID);
    } else {
        request.setAttribute("executionSemesterID", ExecutionSemester.readActualExecutionSemester().getExternalId());
    }
    if (getAndSetRegistration(request) == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    } else {
        return mapping.findForward("prepareEnrollmentViewWarning");
    }
}
 
Example 9
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward prepareShiftEnrollment(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    final Registration registration = getAndSetRegistration(request);
    if (registration == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final String classID = request.getParameter("classId");
    if (classID != null) {
        request.setAttribute("classId", classID);
        return mapping.findForward("showEnrollmentPage");
    }

    ExecutionSemester executionSemester = getDomainObject(request, "executionSemesterID");
    request.setAttribute("executionSemesterID", executionSemester.getExternalId());
    if (readAndSetSelectCoursesParameter(request) == null) {
        return prepareShiftEnrolmentInformation(mapping, request, registration, executionSemester);
    } else {
        return prepareSelectCoursesInformation(mapping, actionForm, request, registration, executionSemester);
    }
}
 
Example 10
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ActionForward unEnroleStudentFromShift(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    final Registration registration = getAndSetRegistration(request);
    if (registration == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final String shiftId = request.getParameter("shiftId");
    final String executionCourseID = request.getParameter("executionCourseID");
    if (!StringUtils.isEmpty(executionCourseID)) {
        request.setAttribute("executionCourseID", executionCourseID);
    }

    try {
        UnEnrollStudentFromShift.runUnEnrollStudentFromShift(registration, shiftId,
                getDomainObject(request, "executionSemesterID"));

    } catch (FenixServiceException e) {
        throw new FenixActionException(e);
    }

    return start(mapping, form, request, response);
}
 
Example 11
Source File: MailingWizardAction.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
    * If the user is not logged in - forwards to login page<br>
    * Gets list of mailinglists for current company. If there are no mailinglists existing - adds error message and
    * forwards to input forward ("mwStart").<br>
    * In other case creates mailing using mailingFactory; initializes mailing (creates default html- and text-template
    * components and mediatype); sets mailing template id if templateID parameter existed in request; sets mailing
    * default target mode; sets mailing into Form; forwards to "next" (currently that is the page for entering mailing
    * name and description)
    *
    * @param mapping The ActionMapping used to select this instance
    * @param form data for the action filled by the jsp
    * @param request request from jsp
    * @param res response
    * @return destination specified in struts-config.xml to forward to next jsp
    * @throws Exception if a exception occurs
    */
public ActionForward start(ActionMapping mapping, ActionForm form,
		HttpServletRequest request, HttpServletResponse res) throws Exception {
	if (!AgnUtils.isUserLoggedIn(request)) {
		return mapping.findForward("logon");
	}

	List<Mailinglist> mlists = mailinglistApprovalService.getEnabledMailinglistsForAdmin(AgnUtils.getAdmin(request));

	if(mlists.size() <= 0) {
		ActionMessages	errors = new ActionMessages();

		errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.mailing.noMailinglist"));
		saveErrors(request, errors);
		return mapping.getInputForward();
	}

	//populate mailing data with info from workflow
	updateForwardParameters(request, true);

	MailingWizardForm aForm = (MailingWizardForm) form;
	ComMailing mailing = mailingFactory.newMailing();

	mailing.init(AgnUtils.getCompanyID(request), getApplicationContext(request));
       Map<String, String> map = AgnUtils.getReqParameters(request);
       String templateIDString = map.get("templateID");
       if (StringUtils.isNotEmpty(templateIDString)) {
           mailing.setMailTemplateID(NumberUtils.toInt(templateIDString));
       }
       mailing.setTargetMode(Mailing.TARGET_MODE_AND);

	setMailingWorkflowParameters(request, mailing);
	aForm.setMailing(mailing);
	aForm.setMailingContentType(ComMailing.MailingContentType.advertising);

	request.setAttribute("isEnableTrackingVeto", configService.getBooleanValue(ConfigValue.EnableTrackingVeto, AgnUtils.getCompanyID(request)));
	
	return mapping.findForward("next");
}
 
Example 12
Source File: ShiftStudentEnrollmentManagerLookupDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward prepareStartViewWarning(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    request.setAttribute("executionSemesterID", request.getParameter("executionSemesterID"));
    if (getAndSetRegistration(request) == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    } else {
        return mapping.findForward("prepareEnrollmentViewWarning");
    }
}
 
Example 13
Source File: ShiftStudentEnrollmentManagerDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ActionForward prepareSelectCoursesInformation(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, final Registration registration, final ExecutionSemester executionSemester) {

    final DynaActionForm form = (DynaActionForm) actionForm;

    final List<ExecutionDegree> executionDegrees =
            executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isPreBolonhaDegree);
    executionDegrees.addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isBolonhaDegree));
    executionDegrees
            .addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isIntegratedMasterDegree));
    executionDegrees.addAll(executionSemester.getExecutionYear().getExecutionDegreesFor(DegreeType::isBolonhaMasterDegree));

    if (executionDegrees.isEmpty()) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final ExecutionDegree selectedExecutionDegree =
            getSelectedExecutionDegree(form, registration, executionSemester, executionDegrees);
    if (selectedExecutionDegree == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    request.setAttribute("selectedExecutionDegree", selectedExecutionDegree);
    form.set("degree", selectedExecutionDegree.getExternalId());

    sortExecutionDegreesByDegreeName(executionDegrees);
    request.setAttribute("executionDegrees", ExecutionDegreesFormat.buildLabelValueBeansForExecutionDegree(executionDegrees));

    request.setAttribute("attendingExecutionCourses", registration.getAttendingExecutionCoursesFor(executionSemester));
    request.setAttribute("executionCoursesFromExecutionDegree", selectedExecutionDegree.getDegreeCurricularPlan()
            .getExecutionCoursesByExecutionPeriod(executionSemester));

    return mapping.findForward("selectCourses");
}
 
Example 14
Source File: MarkSheetDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward prepareSearchMarkSheetPostBack(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) {

    Object object = RenderUtils.getViewState().getMetaObject().getObject();
    RenderUtils.invalidateViewState();
    request.setAttribute("edit", object);

    return mapping.getInputForward();
}
 
Example 15
Source File: FormComponentsAction.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	if (!AgnUtils.isUserLoggedIn(request)) {
		return mapping.findForward("logon");
	} else {
		return mapping.getInputForward();
	}
}
 
Example 16
Source File: ShiftStudentEnrollmentManagerLookupDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionForward proceedToShiftEnrolment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixServiceException {

    checkParameter(request);
    keepInRequest(request, "executionSemesterID");
    final String classIdSelected = readClassSelected(request);

    final Registration registration = getAndSetRegistration(request);
    if (registration == null) {
        addActionMessage(request, "errors.impossible.operation");
        return mapping.getInputForward();
    }

    final ExecutionCourse executionCourse = getExecutionCourse(request);
    final List<SchoolClass> schoolClassesToEnrol =
            readStudentSchoolClassesToEnrolUsingExecutionCourse(request, registration, executionCourse);
    request.setAttribute("schoolClassesToEnrol", schoolClassesToEnrol);

    if (schoolClassesToEnrol.isEmpty()) {
        return mapping.findForward("prepareShiftEnrollment");
    }

    final SchoolClass schoolClass = setSelectedSchoolClass(request, classIdSelected, schoolClassesToEnrol);

    final User userView = getUserView(request);

    final List<InfoShowOccupation> infoClasslessons =
            ReadClassTimeTableByStudent.runReadClassTimeTableByStudent(registration, schoolClass, executionCourse);

    request.setAttribute("infoClasslessons", infoClasslessons);
    request.setAttribute("infoClasslessonsEndTime", Integer.valueOf(getEndTime(infoClasslessons)));

    final List<InfoShowOccupation> infoLessons = ReadStudentTimeTable.run(registration, null);
    request.setAttribute("person", registration.getPerson());
    request.setAttribute("infoLessons", infoLessons);
    request.setAttribute("infoLessonsEndTime", Integer.valueOf(getEndTime(infoLessons)));

    return mapping.findForward("showShiftsToEnroll");
}
 
Example 17
Source File: ManageShiftsDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ActionForward createShift(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    DynaActionForm createShiftForm = (DynaActionForm) form;

    InfoShiftEditor infoShift = new InfoShiftEditor();
    infoShift.setAvailabilityFinal(new Integer(0));
    InfoExecutionCourse infoExecutionCourse =
            RequestUtils.getExecutionCourseBySigla(request, (String) createShiftForm.get("courseInitials"));
    infoShift.setInfoDisciplinaExecucao(infoExecutionCourse);
    infoShift.setInfoLessons(null);
    infoShift.setLotacao((Integer) createShiftForm.get("lotacao"));
    infoShift.setNome((String) createShiftForm.get("nome"));

    String[] selectedShiftTypes = (String[]) createShiftForm.get("shiftTiposAula");
    if (selectedShiftTypes.length == 0) {
        ActionErrors actionErrors = new ActionErrors();
        actionErrors.add("errors.shift.types.notSelected", new ActionError("errors.shift.types.notSelected"));
        saveErrors(request, actionErrors);
        return mapping.getInputForward();
    }

    final List<ShiftType> shiftTypes = new ArrayList<ShiftType>();
    for (String selectedShiftType : selectedShiftTypes) {
        shiftTypes.add(ShiftType.valueOf(selectedShiftType.toString()));
    }

    infoShift.setTipos(shiftTypes);

    // try {
    final InfoShift newInfoShift = CriarTurno.run(infoShift);
    request.setAttribute(PresentationConstants.SHIFT, newInfoShift);

    // } catch (ExistingServiceException ex) {
    // throw new ExistingActionException("O Shift", ex);
    // }

    request.setAttribute(PresentationConstants.EXECUTION_COURSE, infoExecutionCourse);

    return mapping.findForward("EditShift");
}
 
Example 18
Source File: ComMailingWizardAction.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * 
 */
@Override
public ActionForward target(ActionMapping mapping, ActionForm form,
		HttpServletRequest req, HttpServletResponse res) throws Exception {
	if (!AgnUtils.isUserLoggedIn(req)) {
		return mapping.findForward("logon");
	}
	MailingWizardForm aForm = (MailingWizardForm) form;
	Mailing mailing = aForm.getMailing();
	

	MediatypeEmail param = mailing.getEmailParam();
	param.setOnepixel(aForm.getEmailOnepixel());
       prepareTargetPage(req);
	if (aForm.getTargetID() != 0) {
		Collection<Integer> targetGroups = mailing.getTargetGroups();

		if (targetGroups == null) {
			targetGroups = new HashSet<>();
			mailing.setTargetGroups(targetGroups);
		}
		ComTarget aTarget = targetDao.getTarget(aForm.getTargetID(), AgnUtils.getCompanyID(req));
		if (!targetGroups.contains(aForm.getTargetID()) && aTarget != null && aTarget.getDeleted() == 0) {
			targetGroups.add(aForm.getTargetID());
		}
	}

	if (aForm.getRemoveTargetID() != 0) {
		Collection<Integer> aList = aForm.getMailing().getTargetGroups();

		if (aList != null) {
			aList.remove(aForm.getRemoveTargetID());
		}
		return mapping.getInputForward();
	}

	// for the case if the target mode was changed we need to re-generate target expression
       if (aForm.getTargetID() == 0 && aForm.getRemoveTargetID() == 0 && CollectionUtils.isNotEmpty(mailing.getTargetGroups())) {
           mailing.updateTargetExpression();
       }
	return mapping.findForward("next");
}
 
Example 19
Source File: SendMailMarkSheetDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ActionForward prepareSearchSendMailInvalid(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) {

    request.setAttribute("bean", RenderUtils.getViewState().getMetaObject().getObject());
    return mapping.getInputForward();
}
 
Example 20
Source File: StudentOperationsDispatchAction.java    From fenixedu-academic with GNU Lesser General Public License v3.0 3 votes vote down vote up
public ActionForward chooseExecutionDegreeInvalid(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) {

    request.setAttribute("executionDegreeBean", RenderUtils.getViewState().getMetaObject().getObject());

    return mapping.getInputForward();
}