Example usage for org.springframework.ui ModelMap ModelMap

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

Introduction

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

Prototype

public ModelMap() 

Source Link

Document

Construct a new, empty ModelMap .

Usage

From source file:org.esupportail.monitor.web.springmvc.WebController.java

@RequestMapping("VIEW")
protected ModelAndView renderView(RenderRequest request, RenderResponse response) throws Exception {

    ModelMap model = new ModelMap();
    servers = new ArrayList<ServerInfo>();

    for (Iterator i = Config.getInstance().getServers().iterator(); i.hasNext();) {

        ServerInfo s = (ServerInfo) i.next();
        s.getUsers().clear();//from w w  w .  j a v a  2 s  .co  m
        if (InfosCollector.fetch(s, users)) {
            servers.add(s);
        }
    }

    model.put("liste_serveurs", servers);

    return new ModelAndView("view", model);
}

From source file:org.openhealthtools.openatna.web.ErrorController.java

public ModelAndView errors(HttpServletRequest request, HttpServletResponse response, QueryBean queryBean)
        throws Exception {

    ModelMap modelMap = new ModelMap();
    List<? extends ErrorEntity> ents = query(queryBean);
    if (ents != null) {
        List<StringifiedError> list = new ArrayList<StringifiedError>();
        for (ErrorEntity ent : ents) {
            list.add(new StringifiedError(ent));
        }//from  www  .  j  a  va2  s .c o  m
        modelMap.addAttribute("errors", list);
    } else {
        modelMap.addAttribute("errors", new ArrayList());
    }
    modelMap.addAttribute("queryBean", queryBean);
    return new ModelAndView("errorForm", modelMap);
}

From source file:org.ahp.vinavidai.test.controller.TakeTest.java

@RequestMapping(method = RequestMethod.POST, params = "submitAction=Cancel Test")
public ModelAndView cancelTest(@ModelAttribute("takeTest") TakeTestCommand pTakeTestCommand) {
    ModelMap lModelMap = new ModelMap();
    return new ModelAndView("/test/TakeTest.jsp", "testModel", lModelMap);
}

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

/**
 * @see UserFormController#handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)
 *
 *//*  w w  w  . j  av a 2 s  . c  o m*/
@Test
@Verifies(value = "should work for an example", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null, String, User,BindingResult)")
public void handleSubmission_shouldWorkForAnExample() throws Exception {
    WebRequest request = new ServletWebRequest(new MockHttpServletRequest());
    User user = controller.formBackingObject(request, null);
    user.addName(new PersonName("This", "is", "Test"));
    user.getPerson().setGender("F");
    controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "", "Save User", "pass123",
            "pass123", null, null, null, new String[0], "true", null, user, new BindException(user, "user"));
}

From source file:org.jboss.arquillian.warp.extension.spring.container.provider.ErrorsProviderTestCase.java

/**
 * <p>Sets up the test environment.</p>
 *
 * @throws Exception if any error occurs
 *///from w  w w.j a  va 2  s.  com
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {

    initProvider(new ErrorsProvider());

    ModelMap modelMap = new ModelMap();
    modelMap.put(BindingResult.MODEL_KEY_PREFIX + "test", mock(BindingResult.class));
    when(modelAndView.getModel()).thenReturn(modelMap);
}

From source file:org.ala.spatial.services.web.BreakdownController.java

@RequestMapping(value = ACTIONS_BREAKDOWN)
public ModelMap breakdown(HttpServletRequest req) {
    ModelMap m = new ModelMap();

    if (!Utilities.isLoggedIn(req)) {
        m.addAttribute("error", "authentication");
        m.addAttribute("message", "Please authenticate yourself with the ALA system");
    } else {/*from   w ww.j  a  v a2  s  .c  o  m*/
        String useremail = Utilities.getUserEmail(req);

        //m.addAttribute("breakdown", actionDao.getActionBreakdownByType());
        //m.addAttribute("breakdown", actionDao.getActionBreakdownBy("category1",""));

        String forUser = req.getParameter("usr");
        if (forUser != null && !forUser.trim().equals("") && forUser.trim().equals("all")) {
            if (Utilities.isUserAdmin(req)) {
                m.addAttribute("actionsbyday", actionDao.getActionBreakdownByDay());
            } else {
                m.addAttribute("error", "authentication");
                m.addAttribute("message",
                        "Please authenticate yourself with the ALA system with an administrator account");
            }
        } else {
            m.addAttribute("actionsbyday", actionDao.getActionBreakdownByDayUser(useremail));
        }
    }

    return m;
}

From source file:com.mtt.myapp.user.controller.UserControllerTest.java

@Test
public void testGetOne() {
    ModelMap model = new ModelMap();
}

From source file:com.sarm.aussiepayslipgenerator.view.PaySlipControllerTest.java

/**
 *
 * The idea is only to test if the Request Handler completes the process and
 * returns the view. Test of calculatePay method, of class
 * PaySlipController.//w  w w.  j  av  a 2 s.com
 */
@Test
public void testCalculatePay() {

    System.out.println("calculatePay");
    EmployeeInfo employee = new EmployeeInfo();
    employee.setAnnualSalary(75425);
    employee.setFirstName("Bracket3");
    employee.setLastName("Emp3");
    employee.setSuperRate(Double.valueOf("9"));
    employee.setStartDate(new DateTime(2013, 11, 23, 00, 00));
    //
    ModelMap model = new ModelMap();

    String expResult = "employeePaySlip";
    String result = instance.calculatePay(employee, model);

    assertEquals(expResult, result);

}

From source file:com.forexnepal.controller.HomeController.java

@RequestMapping(value = "/exchange_rates/time_by_date/{date}", method = RequestMethod.GET)
public @ResponseBody ModelMap allTimeByDate(@PathVariable(value = "date") Date date) {
    ModelMap map = new ModelMap();

    map.addAttribute("timeByDate", exchangeRatesService.getAllTimeByDate(date));
    return map;/*from w w  w. j a v  a 2 s.c o m*/
}