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:controllers.CircleController.java

@RequestMapping(value = "/post", method = RequestMethod.POST)
public ModelAndView post(@RequestParam(value = "msg") String msg, HttpSession session)
        throws UnsupportedEncodingException, NoSuchAlgorithmException {
    Circle circle = circleDAO.getCircle(id);
    //          //from   w w  w  .  j  a  v  a  2  s  .  c om
    //          mv.addObject("post", msg);
    int pageid = 0;
    circleDAO.postMessage(msg, pageid, (Customer) session.getAttribute("customer"), circle);
    circle = circleDAO.getCircle(id);
    ModelAndView mv = new ModelAndView("circle");
    mv.addObject("Circle", circle);
    return mv;
}

From source file:io.gravitee.oauth2.server.controller.LoginController.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(@RequestParam(value = "error", required = false) String error,
        @RequestParam(value = "logout", required = false) String logout) {

    ModelAndView model = new ModelAndView();
    if (error != null) {
        model.addObject("error", "Invalid username and password!");
    }//from w ww .j  av  a 2  s .c o  m
    if (logout != null) {
        model.addObject("logout", "You've been logged out successfully.");
    }
    model.setViewName("login");
    return model;
}

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

@RequestMapping
public ModelAndView message(HttpServletRequest req, HttpServletResponse res) {
    ModelAndView mv = new ModelAndView("message");
    mv.addObject("messageCode", req.getParameter("messageCode"));
    mv.addObject("messageArguments", req.getParameter("messageArguments"));
    return mv;/* w w w. j  av  a2  s.co m*/
}

From source file:net.indialend.attendance.controller.BranchController.java

@RequestMapping("/list")
public ModelAndView branchList(@RequestParam(defaultValue = "0", required = false) int offset) {
    ModelAndView view = new ModelAndView("branch/branchList");
    view.addObject("branchList", branchService.getBranch(offset, 10));
    return view;/*from   w w w.  j a va  2 s. com*/
}

From source file:com.MyHistory.Controller.JugadorController.java

@RequestMapping(value = "/ResultadoRegistroJugador", method = RequestMethod.GET)
public ModelAndView resultadoRegistrarJugador(HttpServletRequest pRequest) {
    String respuesta = pRequest.getParameter("respuesta");
    ModelAndView mv = new ModelAndView();
    mv.addObject("respuesta", respuesta);
    mv.setViewName("ResultadoRegistro");
    return mv;/*from  w  ww  .j  ava2s .  c  o m*/
}

From source file:org.osmsurround.ra.search.SearchRelationController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView get(@Valid SearchModel searchModel, Errors errors) {
    ModelAndView modelAndView = new ModelAndView("searchResult");
    modelAndView.addObject("tagInfos", tagInfoService.getTagInfos());

    if (errors.hasErrors()) {
        modelAndView.addObject("result", new SearchResult(Collections.EMPTY_LIST));
    } else {//  w w  w.  ja v a  2 s .com
        List<Relation> list = relationSearch.search(searchModel);
        modelAndView.addObject("result", new SearchResult(list));
    }

    return modelAndView;
}

From source file:org.statefulj.demo.ddd.account.application.AccountController.java

@Transition(event = ACCOUNT_DISPLAY_EVENT)
@PreAuthorize("#account.customerId.id == principal.customerId.id")
public ModelAndView displayAccount(Account account, String event) {
    ModelAndView mv = new ModelAndView("account");
    mv.addObject("account", account);
    return mv;//  w ww  .j av  a 2  s. c om
}

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

/**
 * The method retrieves all the users in the database and creates a view that
 * displays all retrieved users// w w w .  java  2s  . c o  m
 * @return A view that displays all the users registered in the database.
 */
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView defaultPage() {
    final ReadAllUsersOutput readAllUsersOutput = serviceProcessor.process(new ReadAllUsersInput());
    final List<UserDto> users = readAllUsersOutput.getUsers();
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(USERS, users);
    model.addObject(ROLES, Role.values());
    model.addObject(COMMAND, new UserDto());
    return model;
}

From source file:com.intel.cosbench.driver.web.MissionSubmissionController.java

private ModelAndView createErrResult(String msg) {
    ModelAndView result = new ModelAndView("submit");
    result.addObject("aInfos", driver.getActiveMissions());
    result.addObject("error", msg);
    return result;
}

From source file:com.library.bookarticlelibrary.controller.AuthorsController.java

@RequestMapping(value = "/authors/author/addauthor", method = RequestMethod.GET)
public ModelAndView displayAddAuthor() {
    ModelAndView model = new ModelAndView("addauthor");
    model.addObject("title", "authors");
    model.addObject("author", new Author());

    return model;
}