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:com.anuz.dummyapi.controller.ClientController.java

@RequestMapping(value = "/content_status/{clientId}", method = RequestMethod.GET)
public ModelMap contentUpdate(@PathVariable("clientId") int clientId) {

    ModelMap map = new ModelMap();

    map.addAttribute("contents", contentUpdateService.getByClientId(clientId));
    return map;//from w w  w  .java 2  s.  c  o m

}

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView ShowSubmissionType(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    CurrentUser = (Users) request.getSession().getAttribute("CurrentUser");
    if (CurrentUser == null) {
        response.sendRedirect("login.htm");
    }//  w w  w .  j a  v  a2s  . co  m

    List<ApprovalStatusType> approvalstatustypelist;
    List<SubmissionType> submissiontypelist;

    approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());

    try {
        int studyid = Integer.parseInt(request.getParameter("studyid"));

        List<studies> li = studiesdao.getStudyDetail(studyid);
        currentstudy = li.get(0);
        submissiontypelist = submissiontypedao.listsubmissiontype(currentstudy.getStudy_id());

        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("currentstudy", currentstudy);
        modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist);
        modelMap.addAttribute("submissiontypelist", submissiontypelist);
        int form = Integer.parseInt(request.getParameter("sub_type_form"));
        if (form == 1)
            modelMap.addAttribute("CurrentFormSubmissionType", "View_Submission_Type_div");
        else
            modelMap.addAttribute("CurrentFormSubmissionType", "Create_Submission_Type_div");

        return new ModelAndView("submission_type", modelMap);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        response.sendRedirect("login.htm");
    }

    return new ModelAndView("submission_type", new ModelMap());
}

From source file:fragment.web.AbstractManageResourceControllerTest.java

/**
 * @author Abhaik/* ww w  .j ava2 s  .  c  o m*/
 * @description : Test to get the SSO Cmd for a Service Provider User through Service Provider User only
 */
@Test
public void testSSOFromSPUserForSelf() {

    setSSOHandler();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    map = new ModelMap();
    Tenant systemTenant = tenantService.getSystemTenant();
    ServiceInstance instance = serviceInstanceDao.find(1L);
    request.setAttribute("effectiveTenant", systemTenant);
    request.setAttribute("isSurrogatedTenant", isSurrogatedTenant(systemTenant, systemTenant.getParam()));

    Map<String, String> resultMap = controller.getSSOCmdString(systemTenant, systemTenant.getParam(),
            instance.getUuid(), map, request, response);
    Assert.assertNotNull(resultMap);

    String status = resultMap.get("status");
    Assert.assertEquals("success", status);

    String cmdString = resultMap.get("cmdString");
    Assert.assertNotNull(cmdString);
    Assert.assertEquals(cmdString, systemTenant.getOwner().getName());

}

From source file:se.vgregion.portal.iframe.controller.CSViewControllerTest.java

@Test
public void testShowView_AuthSiteUserExistSiteKeyExistForm() throws ReadOnlyException {
    PortletPreferences prefs = new MockPortletPreferences();
    initPortletPreferences(prefs);/*from  ww  w .  j a  v a  2 s  . co m*/
    prefs.setValue("src", "http://www.google.com");
    prefs.setValue("auth", "true");
    prefs.setValue("auth-type", "form");
    prefs.setValue("site-key", "test-site-key");

    MockRenderRequest mockReq = new MockRenderRequest(PortletMode.VIEW);
    RenderRequest req = (MockRenderRequest) initPortletRequest(mockReq);

    MockRenderResponse resp = new TestStubMockRenderResponse();

    ModelMap model = new ModelMap();

    String response = controller.showView(prefs, req, resp, model);
    assertEquals("view", response);

    UserSiteCredential siteCredential = (UserSiteCredential) model.get("siteCredential");
    assertEquals("test-user", siteCredential.getUid());
    assertEquals("test-site-key", siteCredential.getSiteKey());
    assertEquals("test-site-user", siteCredential.getSiteUser());
    assertEquals("test-site-password", siteCredential.getSitePassword());

    assertEquals("http://localhost/mockportlet?resourceID=resourceId", model.get("iFrameSrc"));
    assertEquals("http://localhost/mockportlet?resourceID=resourceId", model.get("preIFrameSrc"));

    // Test model
    assertEquals("http://localhost/mockportlet?resourceID=resourceId", model.get("iFrameSrc"));
    assertEquals("http://localhost/", model.get("baseSrc"));
    assertEquals("300", model.get("iFrameHeight"));
    assertEquals("0", model.get("border"));
    assertEquals("#000000", model.get("bordercolor"));
    assertEquals("0", model.get("frameborder"));
    assertEquals("600", model.get("height-maximized"));
    assertEquals("300", model.get("height-normal"));
    assertEquals("0", model.get("hspace"));
    assertEquals("auto", model.get("scrolling"));
    assertEquals("0", model.get("vspace"));
    assertEquals("100%", model.get("width"));
}

From source file:org.motechproject.server.omod.web.controller.MotechModuleFormControllerTest.java

public void testLookupTroubledPhone() {

    String phone = "378378373";
    TroubledPhone tp = new TroubledPhone();
    tp.setId(38903L);// w  w  w  .ja  va  2s . co  m
    tp.setPhoneNumber(phone);

    expect(contextService.getMotechService()).andReturn(motechService);
    expect(motechService.getTroubledPhone(phone)).andReturn(tp);

    replay(contextService, motechService);

    ModelMap model = new ModelMap();
    String path = controller.handleTroubledPhone(phone, null, model);

    verify(contextService, motechService);

    assertEquals(tp, model.get("troubledPhone"));
    assertEquals("/module/motechmodule/troubledphone", path);
}

From source file:com.trenako.web.controllers.RollingStocksControllerTests.java

@Test
public void shouldCreateNewRollingStocks() {
    when(mockResult.hasErrors()).thenReturn(false);

    MultipartFile file = buildFile(MediaType.IMAGE_JPEG);
    UploadRequest req = UploadRequest.create(rollingStock(), file);
    RollingStockForm form = rsForm(file);
    form.setTags("one, two");

    ModelMap model = new ModelMap();

    String viewName = controller.create(form, mockResult, model, mockRedirect);

    assertEquals("redirect:/rollingstocks/{slug}", viewName);

    ArgumentCaptor<RollingStock> arg = ArgumentCaptor.forClass(RollingStock.class);
    verify(service, times(1)).createNew(arg.capture());

    RollingStock savedRs = arg.getValue();
    assertEquals(rollingStock(), savedRs);
    assertTrue("Brand not loaded", savedRs.getBrand().isLoaded());
    assertTrue("Scale not loaded", savedRs.getRailway().isLoaded());
    assertTrue("Scale not loaded", savedRs.getScale().isLoaded());
    assertEquals("[one, two]", savedRs.getTags().toString());

    verify(imgService, times(1)).saveImageWithThumb(eq(req), eq(100));
    verify(mockRedirect, times(1)).addAttribute(eq("slug"), eq("acme-123456"));
    verify(mockRedirect, times(1)).addFlashAttribute(eq("message"),
            eq(RollingStocksController.ROLLING_STOCK_CREATED_MSG));
}

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

@RequestMapping(value = "exchange_rates/latest_date", method = RequestMethod.GET)
public @ResponseBody ModelMap getLatestDate() {
    ModelMap map = new ModelMap();

    map.addAttribute("latestDate", exchangeRatesService.getLatestDate());
    return map;// w  ww  .jav  a2  s .  c o  m
}

From source file:org.ngrinder.user.controller.UserControllerTest.java

@Test
public void testProfile() {
    ModelMap model = new ModelMap();
    String viewName = userController.getOne(getTestUser(), model);
    assertThat(viewName, is("user/info"));
}

From source file:com.anuz.dummyapi.controller.ClientController.java

@RequestMapping(value = "/test/{userId}", method = RequestMethod.GET)
public ModelMap check(@PathVariable("userId") int userId) {

    ModelMap map = new ModelMap();

    map.addAttribute("test", contentUpdateService.getUnsynchronizedContentList(userId));
    return map;/*from www  .ja  v a  2 s .  c  o  m*/

}

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

@RequestMapping(value = "sxs/{analysisId}/{tableType}", method = RequestMethod.GET)
public ModelAndView sxsViewByType(@PathVariable("analysisId") String analysisId,
        @PathVariable("tableType") String tableType, HttpServletRequest req, HttpServletResponse resp)
        throws IOException {
    List tables = getTablesFor(analysisId);

    String json = readFile(AlaspatialProperties.getBaseOutputDir() + File.separator + "output" + File.separator
            + "sitesbyspecies" + File.separator + analysisId + File.separator + tableType + ".json");
    JSONObject jo = JSONObject.fromObject(json);

    jo.put("id", analysisId);
    jo.put("tables", tables);
    jo.put("tablename", tableType);
    jo.put("table", jo.get(tableType));
    jo.remove(tableType);//  w  w  w. jav  a2  s  . com
    jo.put("csvurl", AlaspatialProperties.getBaseOutputURL() + "/output/sitesbyspecies/" + analysisId + "/"
            + tableType + ".csv");
    jo.put("jsonurl", AlaspatialProperties.getBaseOutputURL() + "/output/sitesbyspecies/" + analysisId + "/"
            + tableType + ".json");

    ModelMap m = new ModelMap();
    m.addAttribute("sxs", jo);
    return new ModelAndView("sxs/view", m);

}