Example usage for org.springframework.web.servlet ModelAndView setViewName

List of usage examples for org.springframework.web.servlet ModelAndView setViewName

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView setViewName.

Prototype

public void setViewName(@Nullable String viewName) 

Source Link

Document

Set a view name for this ModelAndView, to be resolved by the DispatcherServlet via a ViewResolver.

Usage

From source file:bc8.movies.controllers.LoginController.java

@RequestMapping(value = "/validateLogin", method = RequestMethod.POST)
public ModelAndView validateLogin(User user, HttpSession session) {
    ModelAndView mv = new ModelAndView("home");

    User currUser = userService.getUser(user);
    if (currUser != null) {
        session.setAttribute("user", currUser);
        mv.setViewName("redirect:/listFavorites");
    }//from w ww  . j a  v a2  s .c o m

    return mv;
}

From source file:org.myjerry.evenstar.web.admin.CreateBlogController.java

public ModelAndView view(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView();

    UserService userService = UserServiceFactory.getUserService();
    if (!userService.isUserAdmin()) {
        mav.setViewName(".noaccess");
    }/*from   w w w .  j a  v a 2s.  c  o m*/

    mav.setViewName(".admin.create.blog");
    return mav;
}

From source file:com.jing.common.controller.CommonController.java

@RequestMapping("404")
public ModelAndView fourofour(HttpServletRequest request, Model model) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/frontend/page404");
    return mv;/*  w  w  w  . j  ava  2 s. com*/
}

From source file:com.jing.common.controller.CommonController.java

@RequestMapping("500")
public ModelAndView fiveoo(HttpServletRequest request, Model model) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/frontend/page500");
    return mv;//from   w  ww . j a  va  2 s.co m
}

From source file:org.openmrs.module.pmtct.web.controller.PmtctConfigurationController.java

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView mav = new ModelAndView();
    mav.setViewName(getViewName());

    Map<String, Object> pmtctConfig = new HashMap<String, Object>();
    try {/*  ww w  .j a v a  2 s .c o m*/
        if (request.getParameter("edit") != null) {
            saveVCTConfiguration(request, mav);
            //boolean reset = (request.getParameter("resetField").compareTo("1") == 0) ? true : false;
            //            saveChanges(request, reset);
        }

        //         config = PMTCTConfiguration.getInstance(request.getRealPath(PMTCTConstants.CONFIGURATION_FILE_LOC));
        //         constants = config.getListOfConstants().get(0);

        request.getSession().setAttribute("pmtctModuleConfigured", "" + PMTCTConfigurationUtils.isConfigured());
        request.getSession().setAttribute("displayHelpMessage", "" + true);
        //         pmtctConfig.put("identifierTypes", config.getIdentifierTypes());
        pmtctConfig.put("gp_encounterTypes", PMTCTConfigurationUtils.getNeededEncounterType());
        pmtctConfig.put("gp_pmtctconcepts", PMTCTConfigurationUtils.getNeededConcept());
        //         pmtctConfig.put("drugOrderTypes", config.getDrugOrderTypes());
        //         pmtctConfig.put("relationshipTypes", config.getRelationshipTypes());
        //         pmtctConfig.put("concepts", config.getConcepts());
        //         pmtctConfig.put("encounterTypes", config.getEncounterTypes());
        //         pmtctConfig.put("programs", config.getPrograms());
        //         pmtctConfig.put("attributeTypes", config.getAttributeTypes());
        //         pmtctConfig.put("pageSize", "" + PMTCTConfigurationUtils.getNumberOfRecordPerPage());
        //         pmtctConfig.put("defaultLocation", "" + PMTCTConfigurationUtils.getDefaultLocationId());
        //         pmtctConfig.put("criticalLevelOfCD4Count", constants.getCriticalLevelOfCD4Count());

        //         pmtctConfig.put("existingLocations", Context.getLocationService().getAllLocations());
        //         pmtctConfig.put("existingPrograms", Context.getProgramWorkflowService().getAllPrograms());
        //         pmtctConfig.put("existingAttributeTypes", Context.getPersonService().getAllPersonAttributeTypes());
        pmtctConfig.put("existingEncTypes", Context.getEncounterService().getAllEncounterTypes());
        pmtctConfig.put("existingIdentifierTypes", Context.getPatientService().getAllPatientIdentifierTypes());
        pmtctConfig.put("existingDrugOrderTypes", Context.getOrderService().getOrderTypes(false));
        pmtctConfig.put("existingRelationshipTypes", Context.getPersonService().getAllRelationshipTypes());

        mav.addObject("pmtctConfigured",
                Context.getAdministrationService().getGlobalPropertyObject("pmtct.configured"));

        mav.addObject("currentRelationShipTypeId", PMTCTConfigurationUtils.getRelationshipTypeId());
        mav.addObject("gp_relationShipType", Context.getAdministrationService()
                .getGlobalPropertyObject("pmtct.relationshiptype.motherchild"));

        mav.addObject("currentDrugOrderTypeId", PMTCTConfigurationUtils.getDrugOrderTypeId());
        mav.addObject("gp_OrderType",
                Context.getAdministrationService().getGlobalPropertyObject("pmtct.ordertype"));

        mav.addObject("currentIdentifierTypeId", PMTCTConfigurationUtils.getCPNIdentifierTypeId());
        mav.addObject("gp_IdentifierType",
                Context.getAdministrationService().getGlobalPropertyObject("pmtct.identifiertype.anc"));

        mav.addObject("pmtctConfig", pmtctConfig);
    } catch (Exception ex) {
        request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR,
                "An error occured when trying to load data. Find the error in the log file.");
        log.error(ex.getMessage());
        ex.printStackTrace();
    }
    return mav;
}

From source file:com.jing.common.controller.CommonController.java

/**
 * ?//from w  w w .  j  a  va  2 s.  co m
 * @param request
 * @param model
 * @return
 */
@RequestMapping("sessionTimeout")
public ModelAndView sessionTimeout(HttpServletRequest request, Model model) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/frontend/index");
    return mv;
}

From source file:com.jing.common.controller.CommonController.java

/**
 * ???// w w w .ja  va 2 s .  c  o m
 * @param request
 * @param model
 * @return
 */
@RequestMapping("noPriv")
public ModelAndView noPriv(HttpServletRequest request, Model model) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/frontend/index");
    return mv;
}

From source file:com.jing.common.controller.CommonController.java

/**
 * ???/*from  ww  w  . j a  v a 2  s  .co m*/
 * @param request
 * @param model
 * @return
 */
@RequestMapping("backendTimeout")
public ModelAndView backendTimeout(HttpServletRequest request, Model model) {
    ModelAndView mv = new ModelAndView();
    mv.setViewName("/admin/login");
    return mv;
}

From source file:com.klm.workshop.controller.participant.BusinessAndObjectivesController.java

/**
 * Show the "Business and objectives" workshop part
 * //from   w w w .j  a  va2 s. c  o m
 * @param model Objects and view
 * @return Business and objectives view
 */
@RequestMapping(value = "/business-objectives/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model) {
    int maxSentencesAmount = 3;

    model.addObject("maxSentencesAmount", maxSentencesAmount);
    model.addObject("workshopStep", CURRENT_STEP);
    model.setViewName("participant/business-objectives/index");
    return model;
}

From source file:com.klm.workshop.controller.participant.IdeateController.java

/**
 * Show the "Ideate" workshop part//  w w  w  . ja  va 2 s.  co  m
 * 
 * @param model Objects and view
 * @return Ideate view
 */
@RequestMapping(value = "/ideate/index", method = RequestMethod.GET)
public ModelAndView index(ModelAndView model) {
    int maxSentencesAmount = 3;

    model.addObject("maxSentencesAmount", maxSentencesAmount);
    model.addObject("workshopStep", CURRENT_STEP);
    model.setViewName("participant/ideate/index");
    return model;
}