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.yilv.web.UserController.java

@RequestMapping("user.do")
public ModelAndView list(HttpServletRequest request, HttpServletResponse response) throws Exception {
    PresenceManager presenceManager = new PresenceManager();
    List<User> userList = userService.getUsers();
    for (User user : userList) {
        if (presenceManager.isAvailable(user)) {
            // Presence presence = presenceManager.getPresence(user);
            user.setOnline(true);//from  w w  w. j  a  v  a 2 s  .com
        } else {
            user.setOnline(false);
        }
        // logger.debug("user.online=" + user.isOnline());
    }
    ModelAndView mav = new ModelAndView();
    mav.addObject("userList", userList);
    mav.setViewName("user/list");
    return mav;
}

From source file:br.com.helio.pocspringmvc.web.ProdutoController.java

@RequestMapping(value = "/editar", method = RequestMethod.GET)
public ModelAndView editar(@RequestParam("codigo") String codigo) {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("produto", produtService.findByCodigo(codigo));
    modelAndView.setViewName("produto/add");
    return modelAndView;
}

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

@RequestMapping(value = "/checkout/{checkinId}", method = RequestMethod.GET)
public ModelAndView checkout(@PathVariable("checkinId") int checkinId) throws SQLException {
    ModelAndView mv = new ModelAndView("admin/checkout/index");
    mv.addObject("Checkin", checkinDAO.checkout(checkinId));
    return mv;//from   w  ww .j  a va  2  s .com
}

From source file:org.schedoscope.metascope.controller.MetascopeErrorController.java

private ModelAndView showErrorView(String view) {
    ModelAndView mav = new ModelAndView("util/" + view);
    mav.addObject("userEntityService", metascopeUserService);
    if (metascopeUserService.isAuthenticated()) {
        mav.addObject("admin", metascopeUserService.isAdmin());
        mav.addObject("userMgmnt", config.withUserManagement());
    }/* ww  w .ja  v a 2  s.  c  o m*/
    return mav;
}

From source file:br.com.helio.pocspringmvc.web.ProdutoController.java

@RequestMapping(value = "/lista", method = RequestMethod.GET)
public ModelAndView showPersons() {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("produtos", produtService.findAll());
    modelAndView.setViewName("produto/lista");

    return modelAndView;
}

From source file:br.com.helio.pocspringmvc.web.ProdutoController.java

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView add() {
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("produto", new Produto());
    modelAndView.setViewName("produto/add");

    return modelAndView;
}

From source file:com.museum_web.controller.ThemeController.java

/**
 *
 *///w  w  w  .  j a v a 2s  . co  m
@RequestMapping("theme")
public ModelAndView list() {
    List<Theme> listTheme = service.listThemes();
    ModelAndView mv = new ModelAndView("theme/list");
    mv.addObject("listTheme", listTheme);
    return mv;
}

From source file:com.trenako.web.controllers.RollingStocksSearchController.java

@RequestMapping(value = "/**", method = RequestMethod.GET)
public ModelAndView search(SearchRequest search, RangeRequest range) {
    ModelAndView mav = new ModelAndView("browse/results");

    mav.addObject("results", service.findByCriteria(search, range));
    mav.addObject("options", ResultsOptionsForm.buildFor(range));
    return mav;/*from  w w w. j a va 2  s.  co m*/
}

From source file:it.jugpadova.controllers.JuggerController.java

@RequestMapping
public ModelAndView confirmUpdateJugger(HttpServletRequest req, HttpServletResponse res) {
    Long id = new Long(req.getParameter("id"));
    Jugger jugger = juggerBo.retrieveJugger(id);
    ModelAndView mv = new ModelAndView("jugger/confirmUpdateJugger");
    mv.addObject("jugger", jugger);
    return mv;//ww  w .  ja v  a  2s.c  o  m
}

From source file:br.eti.fernandoribeiro.sample.spring.SampleController.java

@RequestMapping("/sendMessage")
public ModelAndView sendMessage(@RequestParam("message") final String message) {
    final ModelAndView modelAndView = new ModelAndView("/WEB-INF/jsp/confirmation.jsp");

    modelAndView.addObject("message", message);

    return modelAndView;
}