Java Doc for UrlBasedViewResolver.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » view » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.servlet.view 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.view.AbstractCachingViewResolver
   org.springframework.web.servlet.view.UrlBasedViewResolver

All known Subclasses:   org.springframework.web.servlet.view.AbstractTemplateViewResolver,  org.springframework.web.servlet.view.xslt.XsltViewResolver,  org.springframework.web.servlet.view.jasperreports.JasperReportsViewResolver,  org.springframework.web.servlet.view.InternalResourceViewResolver,
UrlBasedViewResolver
public class UrlBasedViewResolver extends AbstractCachingViewResolver implements Ordered(Code)
Simple implementation of the org.springframework.web.servlet.ViewResolver interface, allowing for direct resolution of symbolic view names to URLs, without explicit mapping definition. This is useful if your symbolic names match the names of your view resources in a straightforward manner (i.e. the symbolic name is the unique part of the resource's filename), without the need for a dedicated mapping to be defined for each view.

Supports AbstractUrlBasedView subclasses like InternalResourceView , org.springframework.web.servlet.view.velocity.VelocityView and org.springframework.web.servlet.view.freemarker.FreeMarkerView . The view class for all views generated by this resolver can be specified via the "viewClass" property.

View names can either be resource URLs themselves, or get augmented by a specified prefix and/or suffix. Exporting an attribute that holds the RequestContext to all views is explicitly supported.

Example: prefix="/WEB-INF/jsp/", suffix=".jsp", viewname="test" -> "/WEB-INF/jsp/test.jsp"

As a special feature, redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction.do" will trigger a redirect to the given URL, rather than resolution as standard view name. This is typically used for redirecting to a controller URL after finishing a form workflow.

Furthermore, forward URLs can be specified via the "forward:" prefix. E.g.: "forward:myAction.do" will trigger a forward to the given URL, rather than resolution as standard view name. This is typically used for controller URLs; it is not supposed to be used for JSP URLs - use logical view names there.

Note: This class does not support localized resolution, i.e. resolving a symbolic view name to different resources depending on the current locale.

Note: When chaining ViewResolvers, a UrlBasedViewResolver always needs to be last, as it will attempt to resolve any view name, no matter whether the underlying resource actually exists.
author:
   Juergen Hoeller
author:
   Rob Harrop
since:
   13.12.2003
See Also:   UrlBasedViewResolver.setViewClass
See Also:   UrlBasedViewResolver.setPrefix
See Also:   UrlBasedViewResolver.setSuffix
See Also:   UrlBasedViewResolver.setRequestContextAttribute
See Also:   UrlBasedViewResolver.REDIRECT_URL_PREFIX
See Also:   AbstractUrlBasedView
See Also:   InternalResourceView
See Also:   org.springframework.web.servlet.view.velocity.VelocityView
See Also:   org.springframework.web.servlet.view.freemarker.FreeMarkerView



Field Summary
final public static  StringFORWARD_URL_PREFIX
     Prefix for special view names that specify a forward URL (usually to a controller after a form has been submitted and processed).
final public static  StringREDIRECT_URL_PREFIX
     Prefix for special view names that specify a redirect URL (usually to a controller after a form has been submitted and processed).


Method Summary
protected  AbstractUrlBasedViewbuildView(String viewName)
     Creates a new View instance of the specified view class and configures it. Does not perform any lookup for pre-defined View instances.

Spring lifecycle methods as defined by the bean container do not have to be called here; those will be applied by the loadView method after this method returns.

Subclasses will typically call super.buildView(viewName) first, before setting further properties themselves.

protected  booleancanHandle(String viewName, Locale locale)
     Indicates whether or not this org.springframework.web.servlet.ViewResolver can handle the supplied view name.
protected  ViewcreateView(String viewName, Locale locale)
     Overridden to implement check for "redirect:" prefix.
public  MapgetAttributesMap()
     Allow Map access to the static attributes for views returned by this resolver, with the option to add or override specific entries.

Useful for specifying entries directly, for example via "attributesMap[myKey]".

protected  ObjectgetCacheKey(String viewName, Locale locale)
     This implementation returns just the view name, as this ViewResolver doesn't support localized resolution.
protected  StringgetContentType()
     Return the content type for all views, if any.
public  intgetOrder()
     Return the order in which this org.springframework.web.servlet.ViewResolver is evaluated.
protected  StringgetPrefix()
     Return the prefix that gets prepended to view names when building a URL.
protected  StringgetRequestContextAttribute()
     Return the name of the RequestContext attribute for all views, if any.
protected  StringgetSuffix()
     Return the suffix that gets appended to view names when building a URL.
protected  ClassgetViewClass()
     Return the view class to be used to create views.
protected  String[]getViewNames()
     Return the view names (or name patterns) that can be handled by this org.springframework.web.servlet.ViewResolver .
protected  voidinitApplicationContext()
    
protected  booleanisRedirectContextRelative()
     Return whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e.
protected  booleanisRedirectHttp10Compatible()
     Return whether redirects should stay compatible with HTTP 1.0 clients.
protected  ViewloadView(String viewName, Locale locale)
    
protected  ClassrequiredViewClass()
     Return the required type of view for this resolver.
public  voidsetAttributes(Properties props)
     Set static attributes from a java.util.Properties object, for all views returned by this resolver.

This is the most convenient way to set static attributes.

public  voidsetAttributesMap(Map attributes)
     Set static attributes from a Map, for all views returned by this resolver.
public  voidsetContentType(String contentType)
     Set the content type for all views.

May be ignored by view classes if the view itself is assumed to set the content type, e.g.

public  voidsetOrder(int order)
     Set the order in which this org.springframework.web.servlet.ViewResolver is evaluated.
public  voidsetPrefix(String prefix)
     Set the prefix that gets prepended to view names when building a URL.
public  voidsetRedirectContextRelative(boolean redirectContextRelative)
     Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e.
public  voidsetRedirectHttp10Compatible(boolean redirectHttp10Compatible)
     Set whether redirects should stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e.

public  voidsetRequestContextAttribute(String requestContextAttribute)
     Set the name of the RequestContext attribute for all views.
public  voidsetSuffix(String suffix)
     Set the suffix that gets appended to view names when building a URL.
public  voidsetViewClass(Class viewClass)
     Set the view class that should be used to create views.
public  voidsetViewNames(String[] viewNames)
     Set the view names (or name patterns) that can be handled by this org.springframework.web.servlet.ViewResolver .

Field Detail
FORWARD_URL_PREFIX
final public static String FORWARD_URL_PREFIX(Code)
Prefix for special view names that specify a forward URL (usually to a controller after a form has been submitted and processed). Such view names will not be resolved in the configured default way but rather be treated as special shortcut.



REDIRECT_URL_PREFIX
final public static String REDIRECT_URL_PREFIX(Code)
Prefix for special view names that specify a redirect URL (usually to a controller after a form has been submitted and processed). Such view names will not be resolved in the configured default way but rather be treated as special shortcut.





Method Detail
buildView
protected AbstractUrlBasedView buildView(String viewName) throws Exception(Code)
Creates a new View instance of the specified view class and configures it. Does not perform any lookup for pre-defined View instances.

Spring lifecycle methods as defined by the bean container do not have to be called here; those will be applied by the loadView method after this method returns.

Subclasses will typically call super.buildView(viewName) first, before setting further properties themselves. loadView will then apply Spring lifecycle methods at the end of this process.
Parameters:
  viewName - the name of the view to build the View instance
throws:
  Exception - if the view couldn't be resolved
See Also:   UrlBasedViewResolver.loadView(String,java.util.Locale)




canHandle
protected boolean canHandle(String viewName, Locale locale)(Code)
Indicates whether or not this org.springframework.web.servlet.ViewResolver can handle the supplied view name. If not, UrlBasedViewResolver.createView(String,java.util.Locale) will return null. The default implementation checks against the configured UrlBasedViewResolver.setViewNames view names .
Parameters:
  viewName - the name of the view to retrieve
Parameters:
  locale - the Locale to retrieve the view for whether this resolver applies to the specified view
See Also:   org.springframework.util.PatternMatchUtils.simpleMatch(StringString)



createView
protected View createView(String viewName, Locale locale) throws Exception(Code)
Overridden to implement check for "redirect:" prefix.

Not possible in loadView, since overridden loadView versions in subclasses might rely on the superclass always creating instances of the required view class.
See Also:   UrlBasedViewResolver.loadView
See Also:   UrlBasedViewResolver.requiredViewClass




getAttributesMap
public Map getAttributesMap()(Code)
Allow Map access to the static attributes for views returned by this resolver, with the option to add or override specific entries.

Useful for specifying entries directly, for example via "attributesMap[myKey]". This is particularly useful for adding or overriding entries in child view definitions.




getCacheKey
protected Object getCacheKey(String viewName, Locale locale)(Code)
This implementation returns just the view name, as this ViewResolver doesn't support localized resolution.



getContentType
protected String getContentType()(Code)
Return the content type for all views, if any.



getOrder
public int getOrder()(Code)
Return the order in which this org.springframework.web.servlet.ViewResolver is evaluated.



getPrefix
protected String getPrefix()(Code)
Return the prefix that gets prepended to view names when building a URL.



getRequestContextAttribute
protected String getRequestContextAttribute()(Code)
Return the name of the RequestContext attribute for all views, if any.



getSuffix
protected String getSuffix()(Code)
Return the suffix that gets appended to view names when building a URL.



getViewClass
protected Class getViewClass()(Code)
Return the view class to be used to create views.



getViewNames
protected String[] getViewNames()(Code)
Return the view names (or name patterns) that can be handled by this org.springframework.web.servlet.ViewResolver .



initApplicationContext
protected void initApplicationContext()(Code)



isRedirectContextRelative
protected boolean isRedirectContextRelative()(Code)
Return whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.



isRedirectHttp10Compatible
protected boolean isRedirectHttp10Compatible()(Code)
Return whether redirects should stay compatible with HTTP 1.0 clients.



loadView
protected View loadView(String viewName, Locale locale) throws Exception(Code)
Delegates to buildView for creating a new instance of the specified view class, and applies the following Spring lifecycle methods (as supported by the generic Spring bean factory):
  • ApplicationContextAware's setApplicationContext
  • InitializingBean's afterPropertiesSet

Parameters:
  viewName - the name of the view to retrieve the View instance
throws:
  Exception - if the view couldn't be resolved
See Also:   UrlBasedViewResolver.buildView(String)
See Also:   org.springframework.context.ApplicationContextAware.setApplicationContext
See Also:   org.springframework.beans.factory.InitializingBean.afterPropertiesSet



requiredViewClass
protected Class requiredViewClass()(Code)
Return the required type of view for this resolver. This implementation returns AbstractUrlBasedView.
See Also:   AbstractUrlBasedView



setAttributes
public void setAttributes(Properties props)(Code)
Set static attributes from a java.util.Properties object, for all views returned by this resolver.

This is the most convenient way to set static attributes. Note that static attributes can be overridden by dynamic attributes, if a value with the same name is included in the model.

Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.
See Also:   org.springframework.beans.propertyeditors.PropertiesEditor
See Also:   AbstractView.setAttributes




setAttributesMap
public void setAttributesMap(Map attributes)(Code)
Set static attributes from a Map, for all views returned by this resolver. This allows to set any kind of attribute values, for example bean references.

Can be populated with a "map" or "props" element in XML bean definitions.
Parameters:
  attributes - Map with name Strings as keys and attribute objects as values
See Also:   AbstractView.setAttributesMap




setContentType
public void setContentType(String contentType)(Code)
Set the content type for all views.

May be ignored by view classes if the view itself is assumed to set the content type, e.g. in case of JSPs.




setOrder
public void setOrder(int order)(Code)
Set the order in which this org.springframework.web.servlet.ViewResolver is evaluated.



setPrefix
public void setPrefix(String prefix)(Code)
Set the prefix that gets prepended to view names when building a URL.



setRedirectContextRelative
public void setRedirectContextRelative(boolean redirectContextRelative)(Code)
Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.

Default is "true": A redirect URL that starts with a slash will be interpreted as relative to the web application root, i.e. the context path will be prepended to the URL.

Redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction.do"
See Also:   RedirectView.setContextRelative
See Also:   UrlBasedViewResolver.REDIRECT_URL_PREFIX




setRedirectHttp10Compatible
public void setRedirectHttp10Compatible(boolean redirectHttp10Compatible)(Code)
Set whether redirects should stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e. delegate to HttpServletResponse.sendRedirect. Turning this off will send HTTP status code 303, which is the correct code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.

Many HTTP 1.1 clients treat 302 just like 303, not making any difference. However, some clients depend on 303 when redirecting after a POST request; turn this flag off in such a scenario.

Redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction.do"
See Also:   RedirectView.setHttp10Compatible
See Also:   UrlBasedViewResolver.REDIRECT_URL_PREFIX




setRequestContextAttribute
public void setRequestContextAttribute(String requestContextAttribute)(Code)
Set the name of the RequestContext attribute for all views.
Parameters:
  requestContextAttribute - name of the RequestContext attribute
See Also:   AbstractView.setRequestContextAttribute



setSuffix
public void setSuffix(String suffix)(Code)
Set the suffix that gets appended to view names when building a URL.



setViewClass
public void setViewClass(Class viewClass)(Code)
Set the view class that should be used to create views.
Parameters:
  viewClass - class that is assignable to the required view class(by default, AbstractUrlBasedView)
See Also:   AbstractUrlBasedView



setViewNames
public void setViewNames(String[] viewNames)(Code)
Set the view names (or name patterns) that can be handled by this org.springframework.web.servlet.ViewResolver . View names can contain simple wildcards such that 'my*', '*Report' and '*Repo*' will all match the view name 'myReport'.
See Also:   UrlBasedViewResolver.canHandle



Methods inherited from org.springframework.web.servlet.view.AbstractCachingViewResolver
public void clearCache()(Code)(Java Doc)
protected View createView(String viewName, Locale locale) throws Exception(Code)(Java Doc)
protected Object getCacheKey(String viewName, Locale locale)(Code)(Java Doc)
public boolean isCache()(Code)(Java Doc)
abstract protected View loadView(String viewName, Locale locale) throws Exception(Code)(Java Doc)
public void removeFromCache(String viewName, Locale locale)(Code)(Java Doc)
public View resolveViewName(String viewName, Locale locale) throws Exception(Code)(Java Doc)
public void setCache(boolean cache)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.