com.arsdigita.cms.dispatcher
Class DefaultTemplateResolver

java.lang.Object
  extended bycom.arsdigita.cms.dispatcher.AbstractTemplateResolver
      extended bycom.arsdigita.cms.dispatcher.DefaultTemplateResolver
All Implemented Interfaces:
TemplateResolver
Direct Known Subclasses:
CategoryItemResolverImpl.CategoryTemplateResolver, DefaultItemTemplateResolver

public class DefaultTemplateResolver
extends AbstractTemplateResolver
implements TemplateResolver

Resolves the JSP template to use for dispatching an item. This replaces TemplateResolver since the latter has a useless API.

In general, the process for resolving a template involves two steps:

  1. The template resolver examines specific properties of the item, the content section, and/or the request itself and selects an appropriate context. A context is simply a token such as "plain" or "fancy".
  2. Based on the selected context, the template resolver identifies an appropriate template for the item. This is a three-step process: (1) the resolver queries for an association between the item and a specific template for the selected context; (2) if no such association exists, the resolver queries the item's content type for a default template to use in the selected context; (3) if a default template is not found, return null (at which point the dispatcher should probably give up and return a 404 error).


Field Summary
 
Fields inherited from class com.arsdigita.cms.dispatcher.AbstractTemplateResolver
TEMPLATE_CONTEXT_PREFIX
 
Fields inherited from interface com.arsdigita.cms.dispatcher.TemplateResolver
versionId
 
Constructor Summary
DefaultTemplateResolver()
           
 
Method Summary
protected  String getDefaultTemplate(ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Returns the default template
protected  String getItemTemplate(ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Returns the template associated with the item (if any)
 String getTemplate(ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Returns the JSP template filename relative to the webapp root.
protected  String getTemplateFilename(Template template, ContentSection section)
          Returns the filename for a Template object
protected  String getTemplateFilename(Template template, ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Returns the filename for a Template object
 String getTemplatePath(Template template)
          Returns the JSP template filename relative to the webapp root for a given Template reference.
protected  String getTemplateXSLFilename(Template template, ContentSection section)
          Returns the filename for a Template object
protected  String getTemplateXSLFilename(Template template, ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Returns the filename for a Template object
 String getTemplateXSLPath(Template template)
          Returns the XSL template filename relative to the webapp root for a given Template reference.
protected  String getTypeTemplate(ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request)
          Deprecated. Use the version that specifies a mime type
protected  String getTypeTemplate(ContentSection section, ContentItem item, javax.servlet.http.HttpServletRequest request, com.arsdigita.mimetypes.MimeType mimeType)
          Returns the template associated with the type (if any)
 
Methods inherited from class com.arsdigita.cms.dispatcher.AbstractTemplateResolver
getTemplateContext, setTemplateContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.arsdigita.cms.dispatcher.TemplateResolver
getTemplateContext, setTemplateContext
 

Constructor Detail

DefaultTemplateResolver

public DefaultTemplateResolver()
Method Detail

getTemplate

public String getTemplate(ContentSection section,
                          ContentItem item,
                          javax.servlet.http.HttpServletRequest request)
Returns the JSP template filename relative to the webapp root.

Specified by:
getTemplate in interface TemplateResolver
Specified by:
getTemplate in class AbstractTemplateResolver
Parameters:
section - The ContentSection for the request
item - The ContentItem for the request
request - The current HttpServletRequest
Returns:
The path to the jsp template.

getTemplatePath

public String getTemplatePath(Template template)
Returns the JSP template filename relative to the webapp root for a given Template reference.

Specified by:
getTemplatePath in interface TemplateResolver
Specified by:
getTemplatePath in class AbstractTemplateResolver
Parameters:
template - The Template to resolve the URL for.
Returns:
The path to the jsp template.

getTemplateXSLPath

public String getTemplateXSLPath(Template template)
Returns the XSL template filename relative to the webapp root for a given Template reference.

Specified by:
getTemplateXSLPath in interface TemplateResolver
Parameters:
template - The Template to resolve the URL for.
Returns:
The path to the xsl template.

getItemTemplate

protected String getItemTemplate(ContentSection section,
                                 ContentItem item,
                                 javax.servlet.http.HttpServletRequest request)
Returns the template associated with the item (if any)


getTypeTemplate

protected String getTypeTemplate(ContentSection section,
                                 ContentItem item,
                                 javax.servlet.http.HttpServletRequest request)
Deprecated. Use the version that specifies a mime type

Returns the template associated with the type (if any)


getTypeTemplate

protected String getTypeTemplate(ContentSection section,
                                 ContentItem item,
                                 javax.servlet.http.HttpServletRequest request,
                                 com.arsdigita.mimetypes.MimeType mimeType)
Returns the template associated with the type (if any)


getDefaultTemplate

protected String getDefaultTemplate(ContentSection section,
                                    ContentItem item,
                                    javax.servlet.http.HttpServletRequest request)
Returns the default template


getTemplateFilename

protected String getTemplateFilename(Template template,
                                     ContentSection section,
                                     ContentItem item,
                                     javax.servlet.http.HttpServletRequest request)
Returns the filename for a Template object


getTemplateXSLFilename

protected String getTemplateXSLFilename(Template template,
                                        ContentSection section,
                                        ContentItem item,
                                        javax.servlet.http.HttpServletRequest request)
Returns the filename for a Template object


getTemplateFilename

protected String getTemplateFilename(Template template,
                                     ContentSection section)
Returns the filename for a Template object


getTemplateXSLFilename

protected String getTemplateXSLFilename(Template template,
                                        ContentSection section)
Returns the filename for a Template object



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC