Package org.springframework.web.portlet

Examples of org.springframework.web.portlet.ModelAndView


    Properties props = new Properties();
    props.setProperty("java.lang.Exception", "error");
    props.setProperty("SomeOddException", "another-error");
    exceptionResolver.setMappedHandlers(Collections.singleton(handler1));
    exceptionResolver.setExceptionMappings(props);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, oddException);
    assertEquals("another-error", mav.getViewName());
  }
View Full Code Here


    props.setProperty("java.lang.Exception", "error");
    props.setProperty("SomeOddException", "another-error");
    props.setProperty("AnotherOddException", "another-some-error");
    exceptionResolver.setMappedHandlers(Collections.singleton(handler1));
    exceptionResolver.setExceptionMappings(props);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, oddException);
    assertEquals("another-some-error", mav.getViewName());
  }
View Full Code Here

    props.setProperty("java.lang.Exception", "error");
    props.setProperty("SomeOddException", "parent-error");
    props.setProperty("SomeOddExceptionChild", "child-error");
    exceptionResolver.setMappedHandlers(Collections.singleton(handler1));
    exceptionResolver.setExceptionMappings(props);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, oddException);
    assertEquals("child-error", mav.getViewName());
  }
View Full Code Here

    Properties props = new Properties();
    props.setProperty("java.lang.Exception", "error");
    props.setProperty("SomeOddException", "parent-error");
    exceptionResolver.setMappedHandlers(Collections.singleton(handler1));
    exceptionResolver.setExceptionMappings(props);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, oddException);
    assertEquals("parent-error", mav.getViewName());
  }
View Full Code Here

   * @param ex the exception that got thrown during handler execution
   * @return the ModelAndView instance
   * @see #setExceptionAttribute
   */
  protected ModelAndView getModelAndView(String viewName, Exception ex) {
    ModelAndView mv = new ModelAndView(viewName);
    if (this.exceptionAttribute != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Exposing Exception as model attribute '" + this.exceptionAttribute + "'");
      }
      mv.addObject(this.exceptionAttribute, ex);
    }
    return mv;
  }
View Full Code Here

    assertEquals(2, exceptionResolver.getOrder());
  }

  public void testDefaultErrorView() {
    exceptionResolver.setDefaultErrorView(DEFAULT_VIEW);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException);
    assertEquals(DEFAULT_VIEW, mav.getViewName());
    assertEquals(genericException, mav.getModel().get(SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE));
  }
View Full Code Here

  }

  public void testDefaultErrorViewDifferentHandler() {
    exceptionResolver.setDefaultErrorView(DEFAULT_VIEW);
    exceptionResolver.setMappedHandlers(Collections.singleton(handler1));
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException);
    assertNull("Handler not mapped - ModelAndView should be null", mav);
  }
View Full Code Here

  }

  public void testDefaultErrorViewDifferentHandlerClass() {
    exceptionResolver.setDefaultErrorView(DEFAULT_VIEW);
    exceptionResolver.setMappedHandlerClasses(new Class[] {String.class});
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException);
    assertNull("Handler not mapped - ModelAndView should be null", mav);
  }
View Full Code Here

    ModelAndView mav = exceptionResolver.resolveException(request, response, handler2, genericException);
    assertNull("Handler not mapped - ModelAndView should be null", mav);
  }

  public void testNullDefaultErrorView() {
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException);
    assertNull("No default error view set - ModelAndView should be null", mav);
  }
View Full Code Here

  }

  public void testNullExceptionAttribute() {
    exceptionResolver.setDefaultErrorView(DEFAULT_VIEW);
    exceptionResolver.setExceptionAttribute(null);
    ModelAndView mav = exceptionResolver.resolveException(request, response, handler1, genericException);
    assertEquals(DEFAULT_VIEW, mav.getViewName());
    assertNull(mav.getModel().get(SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE));
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.portlet.ModelAndView

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.