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:org.easyj.rest.controller.GenericController.java

protected ModelAndView configMAV(Object data, BindingResult result) {
    ModelAndView mav = new ModelAndView();

    mav.addObject(EasyView.PROPERTY_EXCLUSIONS, getExclusions());
    mav.addObject(EasyView.DATA, data);// w  w  w.  java2  s.  c  om
    if (result.hasErrors()) {
        mav.addObject(EasyView.BINDING_RESULT, result);
    }

    return mav;
}

From source file:org.uoiu.platform.web.IndexController.java

@RequestMapping(value = "/index", method = RequestMethod.GET)
public ModelAndView index(@RequestParam(value = "username", required = false) String username,
        @RequestParam(value = "password", required = false) String password,
        @RequestParam(value = "mainAppName", required = false) String mainAppName, Model model,
        HttpServletRequest request) {//  w ww .  j  a v  a  2s  . c om

    System.out.println(username + ":" + password);

    ModelAndView mv = new ModelAndView("index");
    mv.addObject("resourceUrl", "/resources-" + env.getProperty("application.version"));
    mv.addObject("ctx", request.getContextPath());
    mv.addObject("mainAppName", StringUtils.isEmpty(mainAppName) ? "uoiu/platform/PlatformApp" : mainAppName);
    return mv;
}

From source file:com.infinity.controller.ExpController.java

@RequestMapping(value = { "/exp/all/{candidatId}" }, method = RequestMethod.GET)
public ModelAndView allExp(@PathVariable String candidatId) throws IOException {

    ArrayList<Experiences> byIdSearhText = expService.getByIdSearhText(candidatId);

    ModelAndView mv = new ModelAndView("expList");
    mv.addObject("exp", byIdSearhText);

    return mv;//from   w  w  w. ja v  a 2s . com
}

From source file:com.logsniffer.web.wizard2.WizardViewController.java

@RequestMapping(method = RequestMethod.GET)
public ModelAndView renderWizardView(@RequestParam("type") final String beanType)
        throws ClassNotFoundException {
    ConfigBeanWizard<?> wizard = wizardProvider
            .getWizard(beanTypeResolver.resolveTypeClass(beanType, ConfiguredBean.class));
    ModelAndView mv = new ModelAndView(wizard.getWizardView());
    mv.addObject("wizard", wizard);
    return mv;//from  ww w. ja va2  s.c  om
}

From source file:git.irbis.spring3.controllerusageexample.customers.web.ListCustomersCommand.java

ModelAndView execute() {
    ModelAndView mv = new ModelAndView(listCustomersViewName);

    mv.addObject(listCustomersModelName, find());

    return mv;
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractStaticPagesController.java

@RequestMapping(value = { "/errors/*" })
public ModelAndView handle(HttpServletRequest request) {
    ModelAndView viewData = new ModelAndView();
    viewData.addObject("uri", request.getRequestURI());
    viewData.addObject("ref", request.getHeader("Referer"));
    return viewData;
}

From source file:com.kdgregory.pathfinder.test.spring3.pkg2.ControllerE.java

@RequestMapping(value = "/E1")
protected ModelAndView getFoo(HttpServletRequest request, HttpServletResponse response,
        @RequestParam(value = "argle", required = true) String argle,
        @RequestParam(value = "bargle", required = false) Integer bargle,
        @RequestParam(value = "wargle", required = false, defaultValue = "12") int wargle,
        @RequestParam(value = "zargle") Integer zargle) throws Exception {
    ModelAndView mav = new ModelAndView("simple");
    mav.addObject("reqUrl", request.getRequestURI());
    mav.addObject("controller", getClass().getName());
    mav.addObject("argle", argle);
    mav.addObject("bargle", bargle);
    mav.addObject("wargle", wargle);
    return mav;/*  www .j a va2s. co  m*/
}

From source file:com.opencart.controller.MainController.java

@RequestMapping(value = "/product", method = RequestMethod.GET)
public ModelAndView showProduct() {
    ModelAndView mv = new ModelAndView("front/product");
    mv.addObject("subcategories", subcategoryService.list());
    mv.addObject("categories", categoryService.list());
    mv.addObject("products", productService.list());
    return mv;/*from w  w  w.j  ava  2  s.co m*/
}

From source file:controllers.AbstractController.java

@ExceptionHandler(Throwable.class)
public ModelAndView panic(Throwable oops) {
    ModelAndView result;

    result = new ModelAndView("misc/panic");
    result.addObject("name", ClassUtils.getShortName(oops.getClass()));
    result.addObject("exception", oops.getMessage());
    result.addObject("stackTrace", ExceptionUtils.getStackTrace(oops));

    return result;
}

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

/**
 * Show form to create a business objective
 *
 * @param model Objects and view//from   w  w  w .  j  a  v  a2s .  c  o  m
 * @return Form to create a business objective
 */
@RequestMapping(value = "/business-objectives/create", method = RequestMethod.GET)
public ModelAndView create(ModelAndView model) {
    model.addObject("workshopStep", CURRENT_STEP);
    model.setViewName("participant/business-objectives/create");
    return model;
}