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:av1.controller.FornecedorController.java

@RequestMapping("listar-fornecedor")
public ModelAndView listar() {
    FornecedorDAOImpl dao = new FornecedorDAOImpl();
    List<Fornecedor> fornecedor = dao.listar();
    ModelAndView mv = new ModelAndView("fornecedor");
    mv.addObject("fornecedores", fornecedor);
    return mv;//  w  ww .  java2  s  .  c o  m
}

From source file:com.castlemock.web.basis.web.mvc.controller.system.SystemController.java

/**
 * The method creates a view that displays information about the system which the application
 * is running on./*from  w ww. j a v  a2s.  c om*/
 * @return View with all the logged information
 */
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView defaultPage() {
    final GetSystemInformationOutput output = serviceProcessor.process(new GetSystemInformationInput());
    final SystemInformationDto systemInformationDto = output.getSystemInformation();
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(SYSTEM_INFORMATION, systemInformationDto);
    return model;
}

From source file:com.castlemock.web.basis.web.mvc.controller.user.UserController.java

/**
 * The method retrieves a specific user with the provided user id. The retrieved
 * user will be returned with a view and displayed for the Castle Mock' user.
 * @param userId The id of the user that will be retrieved
 * @return A view that displays the retrieved user
 *///from   w  ww .  java2s. c o m
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/{userId}", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String userId) {
    final ReadUserOutput readUserOutput = serviceProcessor.process(new ReadUserInput(userId));
    final UserDto userDto = readUserOutput.getUser();
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(USER, userDto);
    return model;
}

From source file:com.leapfrog.academyspring.controller.CourseController.java

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView add() {
    ModelAndView mv = new ModelAndView("course/addcourse");
    mv.addObject("Course", new Course());
    return mv;/*from  www.  java2  s  .  c  o m*/
}

From source file:com.leapfrog.lfaeventmanager.admin.controller.UserController.java

@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
    ModelAndView mv = new ModelAndView("user/index");
    mv.addObject("userList", userService.getAll());
    return mv;//from ww w  .  j a va2 s .c  om
}

From source file:com.orchestra.portale.controller.GetDeepeningPageController.java

@RequestMapping("/admin/viewallDP")
public ModelAndView viewAll() {
    ArrayList<DeepeningPage> list = (ArrayList<DeepeningPage>) pm.findAllDeepeningPages();
    ModelAndView model = new ModelAndView("viewdps");
    model.addObject("list", list);
    return model;
}

From source file:com.work.petclinic.web.GeneralController.java

@ExceptionHandler(Exception.class)
public ModelAndView handleException(HttpServletRequest req, Exception e) {
    log.warn("In handleException", e);

    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", e);
    mav.addObject("timestamp", new Date());
    mav.addObject("url", req.getRequestURL());
    mav.setViewName("exception");
    return mav;/*from w  w  w. ja v a  2 s .  c  o m*/
}

From source file:org.jtalks.jcommune.web.controller.TopicRenderController.java

/**
 * Method handles GET requests with URI - /topics/{topicId},
 * where {topicId} could be an integer value from 1 to infinity
 *
 * @param topicID the Id os selected Topic
 * @return ModelAndView object which has "renderTopic" as view name and object that represent selected Topic
 *///from w w  w. ja v  a 2s.c om
@RequestMapping(value = "/topics/{topicId}", method = RequestMethod.GET)
public ModelAndView showTopic(@PathVariable("topicId") long topicID) {
    Topic selectedTopic = topicService.getTopicWithPosts(topicID);
    ModelAndView mav = new ModelAndView("renderTopic");
    mav.addObject("selectedTopic", selectedTopic);
    return mav;
}

From source file:com.castlemock.web.basis.web.mvc.controller.event.EventOverviewController.java

/**
 * The method creates a view that displays all the logged information to the user
 * @return View with all the logged information
 *//*from  www.j ava2 s  . c  o m*/
@PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView defaultPage() {
    final List<EventDto> events = eventServiceFacade.findAll();
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(EVENTS, events);
    return model;
}

From source file:com.castlemock.web.mock.rest.web.mvc.controller.application.CreateRestApplicationController.java

@PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(value = "/{projectId}/create/application", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String projectId) {
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(REST_PROJECT_ID, projectId);
    model.addObject(REST_APPLICATION, new RestApplicationDto());
    return model;
}