1. /*
  2. * Copyright 2002-2004 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. package org.springframework.web.servlet.view;
  17. /**
  18. * Abstract base class for URL-based views. Provides a consistent way of
  19. * holding the URL that a View wraps, in the form of a "url" bean property.
  20. * @author Juergen Hoeller
  21. * @since 13.12.2003
  22. */
  23. public abstract class AbstractUrlBasedView extends AbstractView {
  24. private String url;
  25. /**
  26. * Set the URL of the resource that this view wraps.
  27. * The URL must be appropriate for the concrete View implementation.
  28. */
  29. public void setUrl(String url) {
  30. this.url = url;
  31. }
  32. /**
  33. * Return the URL of the resource that this view wraps.
  34. */
  35. public String getUrl() {
  36. return url;
  37. }
  38. /**
  39. * Overridden lifecycle method to check that 'url' property is set.
  40. */
  41. protected void initApplicationContext() {
  42. if (this.url == null) {
  43. throw new IllegalArgumentException("url is required");
  44. }
  45. }
  46. }