Package org.springframework.web.context.request

Examples of org.springframework.web.context.request.NativeWebRequest


  @Test
  public void discoversSimpleSortFromRequest() {

    MethodParameter parameter = getParameterOfMethod("simpleDefault");
    Sort reference = new Sort("bar", "foo");
    NativeWebRequest request = getRequestWithSort(reference);

    assertSupportedAndResolvedTo(request, parameter, reference);
  }
View Full Code Here


      PortletRequest request, MimeResponse response, Object handler, Exception ex) {

    if (handler != null) {
      Method handlerMethod = findBestExceptionHandlerMethod(handler, ex);
      if (handlerMethod != null) {
        NativeWebRequest webRequest = new PortletWebRequest(request, response);
        try {
          Object[] args = resolveHandlerArguments(handlerMethod, handler, webRequest, ex);
          if (logger.isDebugEnabled()) {
            logger.debug("Invoking request handler method: " + handlerMethod);
          }
View Full Code Here

   * Actually resolve the value and check the resolved value is not
   * {@link WebArgumentResolver#UNRESOLVED} absorbing _any_ exceptions.
   */
  public boolean supportsParameter(MethodParameter parameter) {
    try {
      NativeWebRequest webRequest = getWebRequest();
      Object result = this.adaptee.resolveArgument(parameter, webRequest);
      if (result == WebArgumentResolver.UNRESOLVED) {
        return false;
      }
      else {
View Full Code Here

   * Actually resolve the value and check the resolved value is not
   * {@link WebArgumentResolver#UNRESOLVED} absorbing _any_ exceptions.
   */
  public boolean supportsParameter(MethodParameter parameter) {
    try {
      NativeWebRequest webRequest = getWebRequest();
      Object result = this.adaptee.resolveArgument(parameter, webRequest);
      if (result == WebArgumentResolver.UNRESOLVED) {
        return false;
      }
      else {
View Full Code Here

  private void useFacebookProfileImage(Connection<Facebook> connection, Account account, WebRequest request) {
    if (request.getAttribute(USE_FACEBOOK_IMAGE_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
      try {
        profilePictureService.saveProfilePicture(account.getId(), connection.getApi().userOperations().getUserProfileImage());
      } catch (IOException e) {
        NativeWebRequest nativeRequest = (NativeWebRequest) request;
        HttpServletRequest servletRequest = nativeRequest.getNativeRequest(HttpServletRequest.class);
        FlashMap flashMap = RequestContextUtils.getOutputFlashMap(servletRequest);
        flashMap.put("message", Message.warning("Greenhouse was unable to use your Facebook profile picture."));
      }
      request.removeAttribute(USE_FACEBOOK_IMAGE_ATTRIBUTE, WebRequest.SCOPE_SESSION);     
    }
View Full Code Here

        request.setParameter("search.baseInfo.realname_like", "zhang");
        request.setParameter("search.username_eq", "zhang");

        MethodParameter parameter = new MethodParameter(searchable, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        //内部会自动-1,从0开始
        assertEquals(pn - 1, searchable.getPage().getPageNumber());
        assertEquals(pageSize, searchable.getPage().getPageSize());
View Full Code Here

        request.setParameter("search.baseInfo.realname_like", "zhang");
        request.setParameter("search.username_eq", "zhang");

        MethodParameter parameter = new MethodParameter(searchable, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        //内部会自动-1,从0开始
        assertEquals(0, searchable.getPage().getPageNumber());
        assertEquals(10, searchable.getPage().getPageSize());
View Full Code Here

        request.setParameter("search.baseInfo.realname_like", "zhang");
        request.setParameter("search.username_eq", "zhang");

        MethodParameter parameter = new MethodParameter(searchableAndNoPageAndSort, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        assertEquals(null, searchable.getPage());

        Sort expectedSort = new Sort(Sort.Direction.ASC, "baseInfo.realname").and(new Sort(Sort.Direction.DESC, "id"));
View Full Code Here

        request.setParameter("search.baseInfo.realname_like", "zhang");
        request.setParameter("search.username_eq", "zhang");

        MethodParameter parameter = new MethodParameter(searchableAndNoPageAndNoSort, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        assertEquals(null, searchable.getPage());

        assertEquals(null, searchable.getSort());
View Full Code Here

        request.setParameter("sort1.baseInfo.realname", "asc");
        request.setParameter("sort2.id", "desc");

        MethodParameter parameter = new MethodParameter(methodDefaultSearchable, 0);
        NativeWebRequest webRequest = new ServletWebRequest(request);
        Searchable searchable = (Searchable) new SearchableMethodArgumentResolver().resolveArgument(parameter, null, webRequest, null);

        //内部会自动-1,从0开始
        assertEquals(pn - 1, searchable.getPage().getPageNumber());
        assertEquals(pageSize, searchable.getPage().getPageSize());
View Full Code Here

TOP

Related Classes of org.springframework.web.context.request.NativeWebRequest

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.