Example usage for org.springframework.ui ModelMap addAttribute

List of usage examples for org.springframework.ui ModelMap addAttribute

Introduction

In this page you can find the example usage for org.springframework.ui ModelMap addAttribute.

Prototype

public ModelMap addAttribute(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add the supplied attribute under the supplied name.

Usage

From source file:com.arcane.controller.LoginController.java

@RequestMapping(value = "/loginfailed", method = RequestMethod.GET)
public String loginerror(ModelMap model) {
    //return login page
    model.addAttribute("error", "true");
    return "login";

}

From source file:cz.muni.fi.mir.controllers.AnnotationValueController.java

@RequestMapping(value = { "/edit", "/edit/" }, method = RequestMethod.POST)
public ModelAndView editSubmit(
        @Valid @ModelAttribute("annotationValueForm") AnnotationValueForm annotationValueForm,
        BindingResult result, Model model) {
    if (result.hasErrors()) {
        ModelMap mm = new ModelMap();
        mm.addAttribute("annotationValueForm", annotationValueForm);
        mm.addAttribute(model);/*from   w  w  w .j av a2s. co  m*/
    } else {
        annotationValueSerivce.updateAnnotationValue(mapper.map(annotationValueForm, AnnotationValue.class));
    }
    return new ModelAndView("redirect:/annotationvalue/");
}

From source file:org.openmrs.web.controller.user.UserFormControllerTest.java

/**
 * @see UserFormController#handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)
 *
 *///from  w ww .  j  a  va 2  s  .c  o m
@Test
@Verifies(value = "Creates Provider Account when Provider Account Checkbox is selected", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)")
public void handleSubmission_createUserProviderAccountWhenProviderAccountCheckboxIsSelected() throws Exception {
    executeDataSet(TEST_DATA);
    WebRequest request = new ServletWebRequest(new MockHttpServletRequest());
    //A user with userId=2 is preset in the Test DataSet and the relevant details are passed
    User user = Context.getUserService().getUser(2);
    Assert.assertTrue(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty());
    ModelMap model = new ModelMap();
    model.addAttribute("isProvider", false);
    controller.showForm(2, "true", user, model);
    controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "", null, "Test1234",
            "valid secret question", "valid secret answer", "Test1234", false, new String[] { "Provider" },
            "true", "addToProviderTable", user, new BindException(user, "user"));
    Assert.assertFalse(Context.getProviderService().getProvidersByPerson(user.getPerson()).isEmpty());
}

From source file:org.perconsys.controllers.AuthController.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView loginForm(@RequestParam(value = "incorrect", required = false) String incorrect,
        ModelMap model) {
    model.addAttribute("incorrect", (incorrect != null ? incorrect.equalsIgnoreCase("yes") : false));
    ModelAndView mv = new ModelAndView("auth/login_form", "user", new User());
    return mv;/*from   w  w  w  . j ava2s. c o m*/
}

From source file:de.ingrid.interfaces.csw.admin.SchedulingController.java

@RequestMapping(value = TEMPLATE_SCHEDULING_URI, method = RequestMethod.GET)
public String getScheduling(final ModelMap modelMap) {
    modelMap.addAttribute("pattern", _scheduler.getPattern());
    return TEMPLATE_SCHEDULING_VIEW;
}

From source file:org.openmrs.module.systemmetrics.web.controller.SystemPerformanceandUtilizationManageController.java

@RequestMapping(value = "/module/systemmetrics/manage", method = RequestMethod.GET)
public void manage(ModelMap model) {
    model.addAttribute("user", Context.getAuthenticatedUser());

}

From source file:puma.application.evaluation.test.TestController.java

@RequestMapping(value = "/test")
public String index(ModelMap model, @RequestParam("name") String name, @RequestParam("to") String to) {
    model.addAttribute("output", "received request params: name = " + name + ", to = " + to);
    return "test";
}

From source file:com.trenako.web.controllers.admin.AdminOptionsController.java

@RequestMapping(value = "/new", method = RequestMethod.GET)
public String newOption(ModelMap model) {
    model.addAttribute("newForm", new OptionForm());
    return "option/new";
}

From source file:cz.muni.fi.mir.controllers.ExceptionHandlingController.java

private ModelMap prepareModelMap(Exception e, String stacktraceOutput) {
    ModelMap mm = new ModelMap();
    mm.addAttribute("exception", e.getClass().getSimpleName());
    mm.addAttribute("message", e.getMessage());
    mm.addAttribute("stackTrace", stacktraceOutput);

    return mm;/*ww  w  .  j  a  v  a 2  s  .c o m*/
}

From source file:nl.surfnet.coin.selfservice.interceptor.FeatureInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    super.postHandle(request, response, handler, modelAndView);

    if (modelAndView != null) {
        final ModelMap map = modelAndView.getModelMap();
        map.addAttribute("developmentMode", developmentMode);
        map.addAttribute("roles", SpringSecurity.getCurrentUser().getAuthorities());
    }/*w ww .  j  a  va2 s  .  c  om*/
}