01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.web.portlet;
18:
19: import javax.portlet.PortletException;
20:
21: /**
22: * Exception to be thrown on error conditions that should forward
23: * to a specific view with a specific model.
24: *
25: * <p>Can be thrown at any time during handler processing.
26: * This includes any template methods of pre-built controllers.
27: * For example, a form controller might abort to a specific error page
28: * if certain parameters do not allow to proceed with the normal workflow.
29: *
30: * @author Juergen Hoeller
31: * @since 2.0
32: */
33: public class ModelAndViewDefiningException extends PortletException {
34:
35: private ModelAndView modelAndView;
36:
37: /**
38: * Create new ModelAndViewDefiningException with the given ModelAndView,
39: * typically representing a specific error page.
40: * @param modelAndView ModelAndView with view to forward to and model to expose
41: */
42: public ModelAndViewDefiningException(ModelAndView modelAndView) {
43: if (modelAndView == null) {
44: throw new IllegalArgumentException(
45: "modelAndView must not be null in ModelAndViewDefiningException");
46: }
47: this .modelAndView = modelAndView;
48: }
49:
50: /**
51: * Return the ModelAndView that this exception contains for forwarding to.
52: */
53: public ModelAndView getModelAndView() {
54: return modelAndView;
55: }
56:
57: }
|