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

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

Introduction

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

Prototype

public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add an attribute to the model.

Usage

From source file:com.havoc.hotel.admin.controller.CustomerAdminController.java

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView add() throws SQLException {
    ModelAndView mv = new ModelAndView("/admin/customer/add");
    mv.addObject("Customer", new Customer());
    return mv;/* w  w  w  . j a  v  a 2s .  c  o m*/
}

From source file:com.havoc.hotel.admin.controller.CustomerAdminController.java

@RequestMapping(value = "/edit/{customerId}", method = RequestMethod.GET)
public ModelAndView edit(@PathVariable("customerId") int customerId) throws SQLException {
    ModelAndView mv = new ModelAndView("admin/customer/edit");
    mv.addObject("Customer", customerDAO.getById(customerId));
    return mv;/*from ww  w  . j a  v a  2s  . c o  m*/
}

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

/**
 * Show form to update a target audience
 * //w ww.ja  v  a2s  .  com
 * @param model Objects and view
 * @param id The ID of the workshop to update
 * @return Form to update a target audience
 */
@RequestMapping(value = "/target-audience/update/{id}", method = RequestMethod.GET)
public ModelAndView update(ModelAndView model, @PathVariable int id) {
    model.addObject("workshopStep", CURRENT_STEP);
    model.setViewName("participant/target-audience/update");

    return model;
}

From source file:com.logsniffer.web.controller.exception.ExceptionControllerAdvice.java

/**
 * Handles a {@link ResourceNotFoundException}.
 * /*  w w  w. j  a  v  a2  s . co m*/
 * @param ex
 * @return
 */
@ExceptionHandler(ResourceNotFoundException.class)
public ModelAndView handleResourceNotFound(final ResourceNotFoundException ex) {
    logger.info("Catched resource not found exception", ex);
    final ModelAndView mv = new ModelAndView("errors/404");
    mv.addObject("ex", ex);
    return mv;
}

From source file:com.mjeanroy.backbone_isomorphic.views.FrameworkView.java

@RequestMapping(value = "/frameworks/{lang}", method = GET)
public ModelAndView frameworkView(@PathVariable("lang") String lang) throws JsonProcessingException {
    List<Framework> frameworks = frameworkController.query(lang);
    ModelAndView modelAndView = new ModelAndMustacheView("frameworks");
    modelAndView.addObject("frameworks", frameworks);
    modelAndView.addObject("lang_" + lang.toLowerCase(), true);
    modelAndView.addObject("_frameworks_", objectMapper.writeValueAsString(frameworks));
    return modelAndView;
}

From source file:com.rambird.miles.web.VisitController.java

@RequestMapping(value = "/owners/*/pets/{petId}/visits", method = RequestMethod.GET)
public ModelAndView showVisits(@PathVariable int petId) {
    ModelAndView mav = new ModelAndView("visitList");
    mav.addObject("visits", this.rambirdService.findPetById(petId).getVisits());
    return mav;//from   ww w  .jav  a2s .c  o  m
}

From source file:com.rambird.web.VisitController.java

@RequestMapping(value = "/owners/*/pets/{petId}/visits", method = RequestMethod.GET)
public ModelAndView showVisits(@PathVariable int petId) {
    ModelAndView mav = new ModelAndView("visitList");
    mav.addObject("visits", this.clinicService.findPetById(petId).getVisits());
    return mav;//w  ww  .j  a v  a  2 s.co  m
}

From source file:de.dominikschadow.duke.encounters.controller.SessionController.java

/**
 * Shows the login page.//from w  ww .j ava  2 s .  c  o m
 *
 * @return Login URL
 */
@RequestMapping(value = "/login", method = GET)
public ModelAndView login(@RequestParam(value = "error", required = false) String error) {
    ModelAndView model = new ModelAndView("login");

    if (error != null) {
        model.addObject("loginError", true);
    }

    return model;
}

From source file:net.sourceforge.subsonic.controller.LogController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();

    map.put("logEntries", Logger.getLatestLogEntries());
    map.put("logFile", Logger.getLogFile());
    map.put("user", securityService.getCurrentUser(request));

    ModelAndView result = super.handleRequestInternal(request, response);
    result.addObject("model", map);
    return result;
}

From source file:org.owasp.webgoat.controller.StartLesson.java

/**
 * <p>start.</p>/*  www  . jav  a2s.  c  o  m*/
 *
 * @return a {@link ModelAndView} object.
 */
@RequestMapping(path = "startlesson.mvc", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView start() {
    ModelAndView model = new ModelAndView();

    model.addObject("course", course);
    model.addObject("lesson", ws.getCurrentLesson());
    model.setViewName("lesson_content");
    return model;
}