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:net.groupbuy.controller.admin.ArticleController.java

/**
 * //  www .  java  2 s  .co  m
 */
@RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(Pageable pageable, ModelMap model) {
    model.addAttribute("page", articleService.findPage(pageable));
    return "/admin/article/list";
}

From source file:net.groupbuy.controller.admin.PaymentMethodController.java

/**
 * /*w w  w .j  ava  2  s . c  o  m*/
 */
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(ModelMap model) {
    model.addAttribute("methods", Method.values());
    model.addAttribute("shippingMethods", shippingMethodService.findAll());
    return "/admin/payment_method/add";
}

From source file:org.openmrs.module.patientflags.web.FindFlaggedPatientsEmailController.java

/**
 *  Handle the request to create an flag email
 *///  w  ww . j a va2s  .c o m

@RequestMapping(method = RequestMethod.GET)
public ModelAndView processRequest(@ModelAttribute("flag") Flag flag, BindingResult result,
        SessionStatus status) {

    if (result.hasErrors()) {
        throw new APIException("Invalid parameter passed to FindFlaggedPatientsEmailController");
    }

    // get all Patients that trigger the selected Flag
    FlagService flagService = Context.getService(FlagService.class);
    flag = flagService.getFlag(flag.getFlagId());
    Cohort flaggedPatients = flagService.getFlaggedPatients(flag);
    Cohort allPatients = Context.getPatientSetService().getAllPatients();

    // create the model map
    ModelMap model = new ModelMap();
    model.addAttribute("flag", flag);
    model.addAttribute("allPatients", allPatients);
    if (flaggedPatients != null) {
        model.addAttribute("flaggedPatients", flaggedPatients.getMemberIds());
    } else {
        model.addAttribute("flaggedPatients", null);
    }

    // clears the command object from the session
    status.setComplete();

    // displays the query results
    return new ModelAndView("/module/patientflags/findFlaggedPatientsEmailResults", model);
}

From source file:net.groupbuy.controller.admin.ArticleController.java

/**
 * //from   w  w  w  . j  a v  a2s. c om
 */
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add(ModelMap model) {
    model.addAttribute("articleCategoryTree", articleCategoryService.findTree());
    model.addAttribute("tags", tagService.findList(Type.article));
    return "/admin/article/add";
}

From source file:net.groupbuy.controller.admin.PaymentMethodController.java

/**
 * /*from   www.  java 2 s .com*/
 */
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String edit(Long id, ModelMap model) {
    model.addAttribute("methods", Method.values());
    model.addAttribute("shippingMethods", shippingMethodService.findAll());
    model.addAttribute("paymentMethod", paymentMethodService.find(id));
    return "/admin/payment_method/edit";
}

From source file:org.openmrs.module.facilitydata.web.controller.FacilityDataFormListController.java

@RequestMapping("/module/facilitydata/form.list")
public String listForms(ModelMap map) {
    FacilityDataService svc = Context.getService(FacilityDataService.class);
    map.addAttribute("forms", svc.getAllFacilityDataForms());
    return "/module/facilitydata/formList";
}

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

@RequestMapping(value = { "/", "/list", "/list/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.configuration.list}")
public ModelAndView list() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("configurationList", configurationService.getAllCofigurations());

    return new ModelAndView("configuration_list", mm);
}

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

@RequestMapping(value = { "/create", "/create/" }, method = RequestMethod.GET)
@SiteTitle("{entity.configuration.create}")
public ModelAndView createConfiguration() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("configurationForm", new ConfigurationForm());

    return new ModelAndView("configuration_create", mm);
}

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

@RequestMapping(value = { "/view/{id}", "/view/{id}/" }, method = RequestMethod.GET)
@SiteTitle("{entity.configuration.view}")
public ModelAndView viewConfiguration(@PathVariable Long id) {
    ModelMap mm = new ModelMap();
    mm.addAttribute("configurationEntry", configurationService.getConfigurationByID(id));

    return new ModelAndView("configuration_view", mm);
}

From source file:net.groupbuy.controller.admin.ArticleController.java

/**
 * /*  ww  w. ja va  2 s  . c  o m*/
 */
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String edit(Long id, ModelMap model) {
    model.addAttribute("articleCategoryTree", articleCategoryService.findTree());
    model.addAttribute("tags", tagService.findList(Type.article));
    model.addAttribute("article", articleService.find(id));
    return "/admin/article/edit";
}