KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > View


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.servlet;
18
19 import java.util.Map JavaDoc;
20
21 import javax.servlet.http.HttpServletRequest JavaDoc;
22 import javax.servlet.http.HttpServletResponse JavaDoc;
23
24 /**
25  * MVC View for a web interaction. Implementations are responsible for rendering
26  * content, and exposing the model. A single view exposes multiple model attributes.
27  *
28  * <p>This class and the MVC approach associated with it is discussed in Chapter 12 of
29  * <a HREF="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
30  * by Rod Johnson (Wrox, 2002).
31  *
32  * <p>View implementations may differ widely. An obvious implementation would be
33  * JSP-based. Other implementations might be XSLT-based, or use an HTML generation library.
34  * This interface is designed to avoid restricting the range of possible implementations.
35  *
36  * <p>Views should be beans. They are likely to be instantiated as beans by a ViewResolver.
37  * As this interface is stateless, view implementations should be thread-safe.
38  *
39  * @author Rod Johnson
40  * @see org.springframework.web.servlet.view.AbstractView
41  * @see org.springframework.web.servlet.view.InternalResourceView
42  */

43 public interface View {
44
45     /**
46      * Return the content type of the view, if predetermined.
47      * <p>Can be used to check the content type upfront,
48      * before the actual rendering process.
49      * @return the content type String (optionally including a character set),
50      * or <code>null</code> if not predetermined.
51      */

52     String JavaDoc getContentType();
53
54     /**
55      * Render the view given the specified model.
56      * <p>The first step will be preparing the request: In the JSP case,
57      * this would mean setting model objects as request attributes.
58      * The second step will be the actual rendering of the view,
59      * for example including the JSP via a RequestDispatcher.
60      * @param model Map with name Strings as keys and corresponding model
61      * objects as values (Map can also be <code>null</code> in case of empty model)
62      * @param request current HTTP request
63      * @param response HTTP response we are building
64      * @throws Exception if rendering failed
65      */

66     void render(Map JavaDoc model, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc;
67
68 }
69
Popular Tags