KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > view > AbstractUrlBasedView


1 /*
2  * Copyright 2002-2006 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.view;
18
19 import org.springframework.beans.factory.InitializingBean;
20
21 /**
22  * Abstract base class for URL-based views. Provides a consistent way of
23  * holding the URL that a View wraps, in the form of a "url" bean property.
24  *
25  * @author Juergen Hoeller
26  * @since 13.12.2003
27  */

28 public abstract class AbstractUrlBasedView extends AbstractView implements InitializingBean {
29
30     private String JavaDoc url;
31
32
33     /**
34      * Constructor for use as a bean.
35      */

36     protected AbstractUrlBasedView() {
37     }
38
39     /**
40      * Create a new AbstractUrlBasedView with the given URL.
41      * @param url the URL to forward to
42      */

43     protected AbstractUrlBasedView(String JavaDoc url) {
44         this.url = url;
45     }
46
47
48     /**
49      * Set the URL of the resource that this view wraps.
50      * The URL must be appropriate for the concrete View implementation.
51      */

52     public void setUrl(String JavaDoc url) {
53         this.url = url;
54     }
55
56     /**
57      * Return the URL of the resource that this view wraps.
58      */

59     public String JavaDoc getUrl() {
60         return this.url;
61     }
62
63     public void afterPropertiesSet() throws Exception JavaDoc {
64         if (getUrl() == null) {
65             throw new IllegalArgumentException JavaDoc("Property 'url' is required");
66         }
67     }
68
69
70     public String JavaDoc toString() {
71         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(super.toString());
72         sb.append("; URL [").append(getUrl()).append("]");
73         return sb.toString();
74     }
75
76 }
77
Popular Tags