01: /*
02: * Copyright 2002-2006 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.mvc;
18:
19: import javax.portlet.ActionRequest;
20: import javax.portlet.ActionResponse;
21: import javax.portlet.PortletException;
22: import javax.portlet.RenderRequest;
23: import javax.portlet.RenderResponse;
24:
25: import org.springframework.web.portlet.ModelAndView;
26:
27: /**
28: * <p>Trivial controller that transforms the PortletMode to a view name.
29: * The advantage here is that the client is not exposed to
30: * the concrete view technology but rather just to the controller URL;
31: * the concrete view will be determined by the ViewResolver.</p>
32: *
33: * <p>Example: PortletMode.VIEW -> "view"</p>
34: *
35: * <p>This controller does not handle action requests.</p>
36: *
37: * @author William G. Thompson, Jr.
38: * @author John A. Lewis
39: * @since 2.0
40: */
41: public class PortletModeNameViewController implements Controller {
42:
43: public void handleActionRequest(ActionRequest request,
44: ActionResponse response) throws Exception {
45: throw new PortletException(
46: "PortletModeNameViewController does not handle action requests");
47: }
48:
49: public ModelAndView handleRenderRequest(RenderRequest request,
50: RenderResponse response) {
51: return new ModelAndView(request.getPortletMode().toString());
52: }
53:
54: }
|