Example usage for org.springframework.ui Model addAttribute

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

Introduction

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

Prototype

Model addAttribute(String attributeName, @Nullable Object attributeValue);

Source Link

Document

Add the supplied attribute under the supplied name.

Usage

From source file:com.github.dbourdette.glass.web.controller.ConfigurationController.java

@RequestMapping("/configuration")
public String configuration(Model model) throws SchedulerException {
    model.addAttribute("configuration", configuration);

    return "configuration";
}

From source file:com.github.dbourdette.otto.web.controller.admin.ConfigurationController.java

@RequestMapping("/configuration")
public String configuration(@RequestParam(required = false) Integer page, Model model) {
    model.addAttribute("navItem", "configuration");
    model.addAttribute("config", springConfig);
    model.addAttribute("form", ConfigForm.read(config));

    return "admin/configuration";
}

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

@RequestMapping(value = "/usuarios", method = RequestMethod.GET)
public String listUsuarios(Model model) {
    model.addAttribute("usuario", new Usuario());
    model.addAttribute("listUsuarios", this.usuarioService.listUsuarios());
    return "usuarios";
}

From source file:edu.mum.waa.webstore.controller.ProductController.java

@RequestMapping("productdetails/{productId}")
public String getProductDetails(Model model, @PathVariable String productId) {
    model.addAttribute("product", productRepository.getProductById(productId));
    return "product_details";
}

From source file:jpa_bayan.TestController.java

@RequestMapping(value = "/tests", method = RequestMethod.GET)
public String listTests(Model model) {
    model.addAttribute("test", new Test());
    model.addAttribute("listTests", this.testDao.listTests());
    return "test";
}

From source file:jpa_bayan.TestController.java

@RequestMapping("/edit/{id}")
public String editTest(@PathVariable("id") int id, Model model) {
    model.addAttribute("test", this.testDao.getTestById(id));
    model.addAttribute("listTests", this.testDao.listTests());
    return "test";
}

From source file:ltistarter.controllers.BaseController.java

/**
 * Just populate some common model stuff for less repeating
 *
 * @param req       the request/*from  w  ww  . ja  va 2  s  .c  o  m*/
 * @param principal the current security principal (if there is one)
 * @param model     the model
 */
void commonModelPopulate(HttpServletRequest req, Principal principal, Model model) {
    model.addAttribute("today", new Date());
    // TODO real user and pass
    model.addAttribute("basicUser", "admin");
    model.addAttribute("basicPass", "admin");
    // TODO real key and secret?
    model.addAttribute("oauthKey", "key");
    model.addAttribute("oauthSecret", "secret");
    // a little extra request handling stuff
    model.addAttribute("req", req);
    model.addAttribute("reqURI", req.getMethod() + " " + req.getRequestURI());
    // current user
    model.addAttribute("username", principal != null ? principal.getName() : "ANONYMOUS");
}

From source file:ninja.pfventure.sample.ember.PortletViewController.java

@RenderMapping
public String question(Model model) {
    model.addAttribute("releaseInfo", ReleaseInfo.getReleaseInfo());

    System.out.println("=== RunnableTest ===");

    // Anonymous Runnable
    Runnable r1 = new Runnable() {

        @Override//from w w  w.j av  a  2  s . co  m
        public void run() {
            System.out.println("Hello world one!");
        }
    };

    // Lambda Runnable
    Runnable r2 = () -> System.out.println("Hello world two!");

    // Run em!
    r1.run();
    r2.run();
    return "sample-ember/view";
}

From source file:ua.com.rocketlv.spb.MainController.java

@RequestMapping("/add")
public String greeting(@RequestParam(value = "name", required = true, defaultValue = "------") String name,
        @RequestParam(value = "address", required = true, defaultValue = "------") String address,
        @RequestParam(value = "phone", required = true, defaultValue = "------") String phone, Model model) {
    model.addAttribute("name", name);
    Users users = new Users(name, address, phone);
    users.getUsersadd().add(new Usersadd("test information", users));
    users.getUsersadd().add(new Usersadd(" server ", users));
    users.getUsersadd().add(new Usersadd(" individual ", users));
    repository.save(users);/*from w  w  w . jav a 2  s. c  o m*/
    return "greeting";
}

From source file:com.banco.controller.AdminController.java

@RequestMapping(value = "edit", method = RequestMethod.GET)
public String edit(@RequestParam(value = "id") long id, Model m) {
    m.addAttribute("user", userService.getUserById(id));
    return "admin_usuarios_edit";
}