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:org.openmrs.module.hospitalcore.util.RadiologyUtil.java

/**
 * generate data for form from an existing encounter
 * /*from   www.j a  v a2s .  com*/
 * @param model
 * @param encounter
 */
public static void generateDataFromEncounter(Model model, Encounter encounter, RadiologyForm form) {
    if (encounter != null) {
        List<String> inputNames = new ArrayList<String>();
        List<String> inputValues = new ArrayList<String>();
        for (Obs obs : encounter.getAllObs()) {
            inputNames.add(obs.getConcept().getName().getName());
            inputValues.add(getObsValue(obs));
        }
        model.addAttribute("inputNames", inputNames);
        model.addAttribute("inputValues", inputValues);
        model.addAttribute("inputLength", inputValues.size());
    }
}

From source file:net.greghaines.jesque.web.controller.JesqueController.java

private static void addPollController(final Model model, final String path, final boolean poll) {
    final StringBuilder sb = new StringBuilder(64);
    sb.append("<p class=\"poll\">");
    if (poll) {// www .  j av  a 2s. c  o m
        sb.append("Last Updated: ").append(new SimpleDateFormat("HH:mm:ss").format(new Date()));
    } else {
        sb.append("<a href=\"").append(path).append(".poll\" rel=\"poll\">Live Poll</a>");
    }
    sb.append("</p>");
    model.addAttribute("pollController", sb.toString());
    model.addAttribute("poll", poll);
}

From source file:org.openmrs.module.laboratory.web.util.LaboratoryUtil.java

/**
 * generate data for form from an existing encounter
 * //from ww  w .java 2 s.  c o m
 * @param model
 * @param encounter
 */
public static void generateDataFromEncounter(Model model, Encounter encounter) {
    if (encounter != null) {
        List<String> inputNames = new ArrayList<String>();
        List<String> inputValues = new ArrayList<String>();
        for (Obs obs : getOrderedObs(encounter)) {
            inputNames.add(obs.getConcept().getName().getName());
            inputValues.add(getObsValue(obs));
        }
        model.addAttribute("inputNames", inputNames);
        model.addAttribute("inputValues", inputValues);
        model.addAttribute("inputLength", inputValues.size());
    }
}

From source file:com.mobileman.projecth.web.service.PatientDataService.java

private static void changeDate(HttpServletRequest request, Model model, Date date_from, Date date_to) {
    DataHolder data = new DataHolder(request);
    // change date
    data.setDateFrom(date_from);//from   w ww .  java  2s . com
    data.setDateTo(date_to);
    model.addAttribute("date_from_text", DateUtils.germanShortDate2str(date_from));
    model.addAttribute("date_to_text", DateUtils.germanShortDate2str(date_to));
}

From source file:net.jforum.controllers.AdminController.java

/**
 * The main admin page/*w ww  .j  ava 2 s . c om*/
 */
public void main(Model result) {
    result.addAttribute("stats", this.forumRepository.getForumStats());
    result.addAttribute("sessions", this.sessionManager.getLoggedSessions());
    result.addAttribute("totalLoggedUsers", this.sessionManager.getTotalLoggedUsers());
}

From source file:com.chuangtc.controllers.HelloWorldController.java

@RequestMapping("/hello")
public String hello(@RequestParam(value = "name", required = false, defaultValue = "World") String name,
        Model model) {
    model.addAttribute("name", name);
    return "helloworld";
}

From source file:com.orange.clara.cloud.servicedbdumper.controllers.AbstractController.java

public void addDefaultAttribute(Model model) {
    model.addAttribute("appVersion", version);
}

From source file:com.budiana.irpan.belajar.controller.PesertaHtmlController.java

@RequestMapping("/list")
public void daftarPeserta(Model m) {
    m.addAttribute("daftarPeserta", pd.findAll());
}

From source file:br.com.unicamp.webstore.controller.HomeController.java

@RequestMapping("/")
public String welcome(Model model) {
    model.addAttribute("greeting", "Welcome to Web Store!");
    model.addAttribute("tagline", "The one and only amazing webstore");
    return "welcome";
}

From source file:com.mycompany.thymeleafspringapp.controller.WelcomeController.java

@RequestMapping(value = { "/home", "", "/" }, method = RequestMethod.GET)
public String getHome(@RequestParam(value = "name", defaultValue = "user") String name, Model model) {
    model.addAttribute("name", name);
    return "welcome";
}