Package org.springframework.ui

Examples of org.springframework.ui.ModelMap


    }

    @RequestMapping("/users.html")
    public ModelMap usersHandler(HttpServletRequest req) {
        ModelMap rtn = ControllerUtil.getModelMap(req, userService);

        rtn.addAttribute("topUsers", userService.getTopUsers(20));

        return rtn;
    }
View Full Code Here


    public ModelMap schoolsHandler(HttpServletRequest req,
            @RequestParam(value = "startLetter", required = false)
            String startLetter,
            @RequestParam(value = "start", required = false)
            Integer start) {
        ModelMap rtn = ControllerUtil.getModelMap(req, userService);

        if (start == null) {
            start = 0;
        }

        List<School> schools = null;
        if (startLetter == null) {
            startLetter = "";
            schools = schoolService.getTopSchools(start, 20);
        } else {
            schools = schoolService.getSchoolsStarting(startLetter,
                    start, 20);
        }

        rtn.addAttribute("start", start);
        rtn.addAttribute("startLetter", startLetter);
        rtn.addAttribute("schools", schools);

        return rtn;
    }
View Full Code Here

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView forumsHandler(HttpServletRequest req,
            @RequestParam(value = "uniqueForumID", required = false)
            String uniqueForumID) throws InfrastructureException {

        ModelMap rtn = ControllerUtil.getModelMap(req, userService);

        if (uniqueForumID != null) {

            rtn.addAttribute("uniqueForumID", uniqueForumID);

        } else {

            RecentForumPostTopic rfpt = new RecentForumPostTopic();
            PostsList postList = schoolService.getForum(rfpt, 0, 15);

            ForumBootstrap bootstrap = new ForumBootstrap(gwtSerializer,
                    postList, rfpt);

            rtn.addAttribute("bootstrap", bootstrap);

        }

        return new ModelAndView("forums", rtn);
View Full Code Here

            @RequestParam(value = "searchString", required = false)
            String searchString,
            @RequestParam(value = "message", required = false)
            String message) throws SiteException {

        ModelMap rtn = ControllerUtil.getModelMap(req, userService);

        rtn.addAttribute("message", message);
        addResults(rtn, new SearchCommand(searchString));

        return rtn;
    }
View Full Code Here

    @RequestMapping(method = RequestMethod.POST)
    public ModelMap searchHandler(HttpServletRequest req,
            @ModelAttribute("command")
            SearchCommand command) throws SiteException {

        ModelMap myModel = ControllerUtil.getModelMap(req, userService);

        addResults(myModel, command);

        return myModel;
    }
View Full Code Here

        client.friends_get();
       
        FriendsGetResponse response = (FriendsGetResponse)client.getResponsePOJO();
        List<Long> friends = response.getUid();
       
        ModelMap rtn = ControllerUtil.getModelMap(req, userService);

        User user = userService.getUserByNicknameFullFetch("test");

        rtn.addAttribute("viewUser", user);
        rtn.addAttribute("friends", friends);

        return new ModelAndView("facebook/canvas",rtn);

    }
View Full Code Here

        return model;
    }

    public static ModelMap getModelMap(HttpServletRequest req,
            UserService userService) {
        ModelMap rtn = new ModelMap();
        rtn.addAllAttributes(getDefaultModel(req, userService));
        return rtn;
    }
View Full Code Here

   * @param request current HTTP request
   * @param response current HTTP response
   * @return a ModelAndView to render the response
   */
  public Map vetsHandler(HttpServletRequest request, HttpServletResponse response) {
    return new ModelMap(this.clinic.getVets());
  }
View Full Code Here

 
  @Test
  public void viewPerson_ShouldAddAttributeForUser() {
    //creating a mock user
    final User user = new User();
    final ModelMap model = new ModelMap();
    final int modelSize = 3;
    final String username="Canonical";
        user.setUsername(username);
        user.setEntityId(USER_ID);
    String userProfile = new String(ModelKeys.USER_PROFILE);
        Page personProfile = new Page();
        PageLayout pageLayout = new PageLayout();
        pageLayout.setCode(VALID_PAGE_LAYOUT_CODE);
        personProfile.setPageLayout(pageLayout);
   
    expect(userService.getUserByUsername(username)).andReturn(user).once();
        expect(pageService.getPersonProfilePage(user.getEntityId())).andReturn(personProfile);

    replay(userService, pageService);

    String view = profileController.viewProfile(username, model, null);
   
    //assert that the model is not null
    assertThat(model, CoreMatchers.notNullValue());
 
    //assert that the model size is three
    assertThat(model.size(), CoreMatchers.equalTo(modelSize));
   
    //assert that the model does contain an attribute associated with the authenticated user after setUpForm() is called
    assertThat(model.containsAttribute(userProfile), CoreMatchers.equalTo(true));
   
    //assert that the model does not contain authenticated user as null
    assertThat(model.get(userProfile), CoreMatchers.notNullValue());

        assertThat(view, is(ViewNames.PERSON_PROFILE + "." + VALID_PAGE_LAYOUT_CODE));
   
    verify(userService, pageService);
  }
View Full Code Here

    @Test(expected = UsernameNotFoundException.class)
    public void viewPersonProfile_invalidUser() {
        //creating a mock user
        final User user = null;
        final ModelMap model = new ModelMap();
        final int modelSize = 4;
        final String username="Canonical";
        Page personProfile = new Page();
        PageLayout pageLayout = new PageLayout();
        pageLayout.setCode("person_profile");
View Full Code Here

TOP

Related Classes of org.springframework.ui.ModelMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.