Example usage for org.springframework.ui ModelMap ModelMap

List of usage examples for org.springframework.ui ModelMap ModelMap

Introduction

In this page you can find the example usage for org.springframework.ui ModelMap ModelMap.

Prototype

public ModelMap() 

Source Link

Document

Construct a new, empty ModelMap .

Usage

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView CreateUserCV(HttpServletRequest request, HttpServletResponse response) throws Exception {

    List<UserCV> usercvlist;

    List<Users> userslist;/*from   w w  w . j a  v a 2s.c  o m*/

    userslist = userdao.listusers(CurrentUser);

    UserCV usercv = new UserCV();
    String id = request.getParameter("usercv_edit_id");

    if (id != null) {
        int idnum = Integer.parseInt(id);

        if (idnum != 0) {
            //user is editing the approval status type
            if (Integer.parseInt(request.getParameter("upload_cv")) == 2) {
                //editing user cv but not uploaded new cv
                System.out.println("editing..kk");
                CVitem = null;
                UserCV temp = new UserCV();
                temp = usercvdao.find(idnum);
                usercv.setData(temp.getData());
                usercv.setFilename(temp.getFilename());
                usercv.setType(temp.getType());
            }
            usercv.setUser_cv_id(idnum);
            String str = request.getParameter("usercv_date_created");
            String delimeter = "-";
            String[] temp;
            temp = str.split(delimeter);
            str = temp[0] + "-" + temp[1] + "-" + temp[2];
            java.sql.Date datecreated = java.sql.Date.valueOf(str);
            usercv.setDate_created(datecreated);
            usercv.setCreated_by(Integer.parseInt(request.getParameter("usercv_created_by")));
            usercv.setModified_by((int) CurrentUser.getUser_id());

        } else {
            usercv.setModified_by((int) CurrentUser.getUser_id());
            usercv.setCreated_by((int) CurrentUser.getUser_id());
        }

        String str = request.getParameter("received_date");
        String delimeter = "-";
        String[] temp;
        temp = str.split(delimeter);
        str = temp[0] + "-" + temp[1] + "-" + temp[2];
        java.sql.Date received_date = java.sql.Date.valueOf(str);
        usercv.setReceived_dt(received_date);
        usercv.setUser_id(Integer.parseInt(request.getParameter("user_id")));
        usercv.setStudy_id(currentstudy.getStudy_id());
        usercv.setFile_description(request.getParameter("cv_file_description"));

        usercvlist = usercvdao.listusercv(currentstudy.getStudy_id());

        int Message = usercvdao.UploadDocument(CVitem, usercv, idnum);

        CVitem = null;
        try {
            if (Message == 1) {
                usercvlist = usercvdao.listusercv(currentstudy.getStudy_id());
            }
            ModelMap modelMap = new ModelMap();
            modelMap.addAttribute("currentstudy", currentstudy);
            if (idnum == 0) {
                modelMap.addAttribute("CurrentFormUserCV", "Create_UserCV_div");
            } else {
                if (Message == 3) {
                    modelMap.addAttribute("EEMessage", "User CV cannot be updated at this time !");
                } else if (Message == 4) {
                    modelMap.addAttribute("ESMessage", "User CV successfully updated...");
                    usercvlist = usercvdao.listusercv(currentstudy.getStudy_id());
                }
                modelMap.addAttribute("CurrentFormUserCV", "View_UserCV_div");
            }

            modelMap.addAttribute("usercvlist", usercvlist);
            modelMap.addAttribute("userslist", userslist);
            modelMap.addAttribute("MessageCode", Message);
            return new ModelAndView("usercv", modelMap);

        } catch (Exception expObj) {
            return new ModelAndView("usercv");
        }

    }

    ModelMap modelMap = new ModelMap();
    modelMap.addAttribute("CurrentFormUserCV", "Create_UserCV_div");
    return new ModelAndView("usercv", modelMap);
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractSubscriptionController.java

@RequestMapping(value = ("/browse_catalog"), method = RequestMethod.GET)
public String anonymousCatalog(ModelMap map,
        @RequestParam(value = "serviceInstanceUUID", required = false) final String serviceInstanceUUID,
        @RequestParam(value = "currencyCode", required = false) String currencyCode,
        @RequestParam(value = "resourceType", required = false) final String resourceType,
        @RequestParam(value = "channelCode", required = false) final String channelCode,
        final HttpServletRequest request) {
    logger.debug("### anonymousCatalog method starting...(GET)");
    final String successView = "anonymous.catalog";
    if (config.getValue(Names.com_citrix_cpbm_public_catalog_display).equals("true")) {

        Channel channel = null;/*from  w  w  w  .  j a v a  2 s.  c om*/
        if (StringUtils.isNotBlank(channelCode)) {
            channel = channelService.locateByChannelCode(channelCode);
        } else {
            channel = channelService.getDefaultServiceProviderChannel();
        }

        final Catalog catalog = channel.getCatalog();
        List<CurrencyValue> currencies = catalog.getSupportedCurrencyValuesByOrder();
        map.addAttribute("channel", channel);
        map.addAttribute("currencies", currencies);
        map.addAttribute("anonymousBrowsing", true);
        CurrencyValue currency = currencies.get(0);
        if (StringUtils.isNotBlank(currencyCode)) {
            currency = currencyValueService.locateBYCurrencyCode(currencyCode);
        }
        map.addAttribute("selectedCurrency", currency);
        map.addAttribute(UserContextInterceptor.MIN_FRACTION_DIGITS,
                Currency.getInstance(currency.getCurrencyCode()).getDefaultFractionDigits());

        final Tenant tenant = tenantService.getSystemTenant();
        final Channel finalChannel = channel;
        Map<String, Object> finalMap = privilegeService
                .runAsPortal(new PrivilegedAction<Map<String, Object>>() {

                    @Override
                    public Map<String, Object> run() {
                        ModelMap modelMap = new ModelMap();
                        try {
                            getResourceComponentsAndFilterData(tenant, null, serviceInstanceUUID, null,
                                    resourceType, modelMap, request, successView, finalChannel.getName());
                        } catch (ConnectorManagementServiceException e) {
                            logger.debug("Error occured ", e);
                        }
                        return modelMap;
                    }
                });
        map.addAllAttributes(finalMap);
        map.addAttribute("supportedLocaleList", this.getLocaleDisplayName(listSupportedLocales()));
        // anonymousBrowsing and preview catalog will have default UI Because in cutom UI SSO happens which can leads to
        // security threats
        map.addAttribute("customEditorTag", null);
        map.addAttribute("customComponentSelector", null);
    } else {
        throw new NoSuchDefinitionException();
    }
    return successView;
}

From source file:com.virtusa.akura.student.controller.StudentAcademicLifeController.java

/**
 * handle POST requests for Academic-details - student achievement details edit action.
 * // w ww.j  av  a  2  s.com
 * @param request - HttpServletRequest.
 * @param session - HttpSession.
 * @return the name of the view.
 * @throws AkuraAppException throws when exception occurs.
 */
@RequestMapping(value = ACTION_FOR_EDIT_ACHIEVEMENT, method = RequestMethod.POST)
public ModelAndView editAchievementDetails(HttpServletRequest request, HttpSession session)
        throws AkuraAppException {

    ModelMap modelMap = new ModelMap();
    String selectedStuAchievementId = request.getParameter(SELECTED_STUDENT_ACHIEVEMENT_ID);

    int studentClassInfoId = (request.getParameter(SELECTED_GRADE) != null)
            ? (Integer.parseInt(request.getParameter(SELECTED_GRADE)))
            : 0;
    StudentClassInfo studentClassInfo = studentService.findStudentClassInfoById(studentClassInfoId);
    String yearI = DateUtil.getStringYear(studentClassInfo.getYear());

    if (!"".equals(selectedStuAchievementId) && !"".equals(yearI)) {

        String description = request.getParameter(ACHIEVEMENT_TEXT_AREA).trim();
        if (!"".equals(description)) {
            int intselectedStudAchievementId = Integer.parseInt(selectedStuAchievementId);
            Achievement studentAchievementObj = studentService
                    .findAchievementById(intselectedStudAchievementId);
            if (studentAchievementObj != null) {

                String studentAchievementDescription = description.replaceAll("( )+", " ");
                int studentId = studentAchievementObj.getStudent().getStudentId();
                Date yearNew = studentAchievementObj.getYear();

                if (!isExistsAchievement(studentId, studentAchievementDescription, yearNew)) {

                    studentAchievementObj.setDescription(studentAchievementDescription);
                    studentService.editAchievement(studentAchievementObj);
                } else {
                    request.setAttribute(ACHIEVEMENT_TEXT_AREA, description);
                    populateErrorMessages(modelMap, ERROR_MSG_KEY_DUPLICATE_ACHIEVEMENT_TYPE, ACHIEVEMENT);
                }
            }
        } else {
            request.setAttribute(ACHIEVEMENT_TEXT_AREA, description);
            populateErrorMessages(modelMap, ERROR_MSG_KEY_MANDATORY_FIELDS, ACHIEVEMENT);
        }
        modelMap.addAttribute(ATTR_NAME_YEAR, yearI);
    }
    return showMarks(request, modelMap, session);
}

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView CreateTraining(HttpServletRequest request, HttpServletResponse response) throws Exception {

    List<ApprovalStatusType> approvalstatustypelist;

    List<Training> traininglist;

    approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());

    Training training = new Training();
    String id = request.getParameter("training_edit_id");
    int idnum = Integer.parseInt(id);

    if (idnum != 0) {
        //user is editing the approval status type
        training.setTraining_id(idnum);//from   w  ww . j  av  a2s .  c  om
        String str = request.getParameter("training_date_created");

        String delimeter = "-";
        String[] temp;
        temp = str.split(delimeter);
        str = temp[0] + "-" + temp[1] + "-" + temp[2];
        java.sql.Date datecreated = java.sql.Date.valueOf(str);
        training.setDate_created(datecreated);
        training.setCreated_by(Integer.parseInt(request.getParameter("training_created_by")));
        training.setModified_by((int) CurrentUser.getUser_id());

    } else {
        training.setModified_by((int) CurrentUser.getUser_id());
        training.setCreated_by((int) CurrentUser.getUser_id());
    }

    training.setCode(request.getParameter("training_code").trim());
    training.setName(request.getParameter("training_name").trim());
    training.setDescription(request.getParameter("training_description"));
    training.setStudy_id(currentstudy.getStudy_id());

    //=====================================================create approval status type========================================================//
    if (idnum == 0) {
        int Message = trainingdao.saveTraining(training);
        try {
            traininglist = trainingdao.listtrainings(currentstudy.getStudy_id());
            //            if(Message == 1){
            //               traininglist = trainingdao.listtrainings(currentstudy.getStudy_id());
            //            }
            ModelMap modelMap = new ModelMap();
            modelMap.addAttribute("currentstudy", currentstudy);
            modelMap.addAttribute("CurrentFormTrainingType", "Create_Training_div");
            modelMap.addAttribute("traininglist", traininglist);
            modelMap.addAttribute("MessageCode", Message);
            return new ModelAndView("training_type", modelMap);

        }

        catch (Exception expObj) {
            return new ModelAndView("training_type");
        }

    } else {
        int Message = trainingdao.editTraining(training);
        try {
            ModelMap modelMap = new ModelMap();
            if (Message == 0) {
                modelMap.addAttribute("ETError", "Training cannot be updated at this time !");
            } else if (Message == 1) {
                modelMap.addAttribute("ETSuccess", "Training updated successfully ...");
            }
            traininglist = trainingdao.listtrainings(currentstudy.getStudy_id());

            modelMap.addAttribute("currentstudy", currentstudy);
            modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist);
            modelMap.addAttribute("CurrentFormTrainingType", "View_Training_div");
            modelMap.addAttribute("traininglist", traininglist);
            return new ModelAndView("training_type", modelMap);

        }

        catch (Exception expObj) {
            return new ModelAndView("training_type");
        }

    }

}

From source file:com.virtusa.akura.student.controller.StudentAcademicLifeController.java

/**
 * handle POST requests for Academic-details - student achievement details delete action.
 * //ww w .j a v  a  2s  .  c  o m
 * @param request - HttpServletRequest.
 * @param session - HttpSession.
 * @return the name of the view.
 * @throws AkuraAppException throws when exception occurs.
 */
@RequestMapping(value = ACTION_FOR_DELETE_ACHIEVEMENT, method = RequestMethod.POST)
public ModelAndView deleteAchievementDetails(HttpServletRequest request, HttpSession session)
        throws AkuraAppException {

    String selectedStuAchievementId = request.getParameter(SELECTED_STUDENT_ACHIEVEMENT_ID);

    StudentClassInfo studentClassInfo = studentService
            .findStudentClassInfoById(Integer.parseInt(request.getParameter(SELECTED_GRADE)));

    int intselectedStudAchievementId = Integer.parseInt(selectedStuAchievementId);
    studentService.deleteAchievement(intselectedStudAchievementId);

    ModelMap modelMap = new ModelMap();
    modelMap.addAttribute(ATTR_NAME_YEAR, DateUtil.getStringYear(studentClassInfo.getYear()));
    return showMarks(request, modelMap, session);
}

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView CreateSubmissionType(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    List<SubmissionType> submissiontypelist;

    submissiontypelist = submissiontypedao.listsubmissiontype(currentstudy.getStudy_id());

    SubmissionType submissiontype = new SubmissionType();
    submissiontype.setStudy_id(currentstudy.getStudy_id());
    String id = request.getParameter("edit_id_submission_type");
    int idnum = Integer.parseInt(id);

    if (idnum != 0) {
        //user is editing the approval status type
        submissiontype.setSubmission_type_id(idnum);
        String str = request.getParameter("date_created");
        String delimeter = "-";
        String[] temp;//from   ww w .  j a va 2  s.c  o m
        temp = str.split(delimeter);
        str = temp[0] + "-" + temp[1] + "-" + temp[2];
        java.sql.Date datecreated = java.sql.Date.valueOf(str);
        submissiontype.setDate_created(datecreated);
        submissiontype.setCreated_by(Integer.parseInt(request.getParameter("created_by")));
        submissiontype.setModified_by((int) CurrentUser.getUser_id());

    } else {
        submissiontype.setModified_by((int) CurrentUser.getUser_id());
        submissiontype.setCreated_by((int) CurrentUser.getUser_id());
    }

    submissiontype.setCode(request.getParameter("code").trim());
    submissiontype.setName(request.getParameter("name").trim());
    submissiontype.setDescription(request.getParameter("description"));

    //=====================================================create approval status type========================================================//

    if (idnum == 0) {
        int Message = submissiontypedao.saveSubmissionType(submissiontype);
        try {
            if (Message == 1) {
                submissiontypelist = submissiontypedao.listsubmissiontype(currentstudy.getStudy_id());
            }

            ModelMap modelMap = new ModelMap();
            modelMap.addAttribute("currentstudy", currentstudy);
            modelMap.addAttribute("CurrentFormSubmissionType", "Create_Submission_Type_div");
            modelMap.addAttribute("submissiontypelist", submissiontypelist);
            modelMap.addAttribute("MessageCode", Message);
            return new ModelAndView("submission_type", modelMap);

        } catch (Exception expObj) {
            return new ModelAndView("submission_type");
        }
    } else {
        int Message = submissiontypedao.editSubmissionType(submissiontype);
        try {
            submissiontypelist = submissiontypedao.listsubmissiontype(currentstudy.getStudy_id());
            ModelMap modelMap = new ModelMap();
            if (Message == 0) {
                modelMap.addAttribute("ESEMessage", "Submission type cannot be edited at this time !");
            } else if (Message == 1) {
                modelMap.addAttribute("ESSMessage", "Submission type successfully updated...");
            }
            modelMap.addAttribute("currentstudy", currentstudy);
            modelMap.addAttribute("CurrentFormSubmissionType", "View_Submission_Type_div");
            modelMap.addAttribute("submissiontypelist", submissiontypelist);
            return new ModelAndView("submission_type", modelMap);

        } catch (Exception expObj) {
            return new ModelAndView("submission_type");
        }
    }

}

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView CreateApprovalStatusType(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    List<ApprovalStatusType> approvalstatustypelist;

    approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());

    ApprovalStatusType approvalstatustype = new ApprovalStatusType();
    String id = request.getParameter("edit_id_approval_status");
    int idnum = Integer.parseInt(id);

    if (idnum != 0) {
        //user is editing the approval status type
        approvalstatustype.setApproval_status_type_id(idnum);
        String str = request.getParameter("date_created");

        // this is not a right approach 
        /*   String delimeter = "-";
        String[] temp;//w  ww.  j  a  v a 2s  . c  o m
        temp = str.split(delimeter);
        str = temp[0]  + "-" + temp[1] + "-" + temp[2];
         */
        java.sql.Date datecreated = java.sql.Date.valueOf(str);
        approvalstatustype.setDate_created(datecreated);
        approvalstatustype.setCreated_by(Integer.parseInt(request.getParameter("created_by")));
        approvalstatustype.setModified_by((int) CurrentUser.getUser_id());

    } else {
        approvalstatustype.setModified_by((int) CurrentUser.getUser_id());
        approvalstatustype.setCreated_by((int) CurrentUser.getUser_id());
    }

    approvalstatustype.setCode(request.getParameter("code").trim());
    approvalstatustype.setName(request.getParameter("name").trim());
    approvalstatustype.setDescription(request.getParameter("description"));
    approvalstatustype.setStudy_id(currentstudy.getStudy_id());

    //=====================================================create approval status type========================================================//
    if (idnum == 0) {
        int Message = approvalstatustypedao.saveApprovalStatusType(approvalstatustype);
        try {
            approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());
            ModelMap modelMap = new ModelMap();
            modelMap.addAttribute("currentstudy", currentstudy);
            modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist);
            modelMap.addAttribute("CurrentFormApprovalType", "Create_Approval_Status_Type_div");
            modelMap.addAttribute("MessageCode", Message);
            return new ModelAndView("trials", modelMap);

        } catch (Exception expObj) {
            return new ModelAndView("trials");
        }
    }
    //=====================================================edit approval status type========================================================//
    else {

        int Message = approvalstatustypedao.editApprovalStatusType(approvalstatustype);
        approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());
        ModelMap modelMap = new ModelMap();

        if (Message == 0) {
            modelMap.addAttribute("EEMessage", "Approval Status Type cannot be updated at this time !");
        } else {
            modelMap.addAttribute("ESMessage", "Approval Status type successfully updated...");
        }
        modelMap.addAttribute("currentstudy", currentstudy);
        modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist);
        modelMap.addAttribute("CurrentFormApprovalType", "View_Approval_Status_Type_div");
        return new ModelAndView("trials", modelMap);
    }
}

From source file:fragment.web.RegistrationControllerTest.java

@Test
public void testSignupStep1() {
    ModelMap model = new ModelMap();
    String register = controller.signupStep1(model, request);
    Assert.assertEquals(register, new String("register.account_type"));
}

From source file:fragment.web.RegistrationControllerTest.java

@Test
public void testUserInfo() {
    ModelMap model = new ModelMap();
    UserRegistration registration = new UserRegistration();
    registration.setAcceptedTerms(true);
    AccountType disposition = accountTypeDAO.getTrialAccountType();
    BindingResult result;//from www .  j a v  a2s .  co  m
    try {
        result = setupRegistration(disposition, registration);
        String register = controller.userInfo(registration, result, model, null, status, request);
        Assert.assertEquals("register.moreuserinfo", register);
    } catch (Exception e) {
        Assert.fail();
    }

}