org.duracloud.duradmin.view.tiles2
Class TilesConfigurer

java.lang.Object
  extended by org.duracloud.duradmin.view.tiles2.TilesConfigurer
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.web.context.ServletContextAware

public class TilesConfigurer
extends java.lang.Object
implements org.springframework.web.context.ServletContextAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Helper class to configure Tiles2 for the Spring Framework. See http://tiles.apache.org for more information about Tiles, which basically is a templating mechanism for JSP-based web applications.

The TilesConfigurer simply configures a TilesContainer using a set of files containing definitions, to be accessed by TilesView instances.

TilesViews can be managed by any ViewResolver. For simple convention-based view resolution, consider using UrlBasedViewResolver with the "viewClass" property set to "org.springframework.web.servlet.view.tiles2.TilesView".

A typical TilesConfigurer bean definition looks as follows:

 <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
   <property name="definitions">
     <list>
       <value>/WEB-INF/defs/general.xml</value>
       <value>/WEB-INF/defs/widgets.xml</value>
       <value>/WEB-INF/defs/administrator.xml</value>
       <value>/WEB-INF/defs/customer.xml</value>
       <value>/WEB-INF/defs/templates.xml</value>
     </list>
   </property>
 </bean>
The values in the list are the actual files containing the definitions.

Since:
2.5
Author:
Juergen Hoeller, Richard Jr Barabé
See Also:
TilesView, UrlBasedViewResolver

Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
TilesConfigurer()
           
 
Method Summary
 void afterPropertiesSet()
          Creates and exposes a TilesContainer for this web application.
protected  org.apache.tiles.TilesContainer createTilesContainer()
          Create a TilesContainer for this web application.
 void destroy()
          Removes the TilesContainer from this web application.
 void setDefinitions(java.lang.String[] definitions)
          Set the Tiles definitions, i.e.
 void setDefinitionsFactoryClass(java.lang.Class<?> definitionsFactoryClass)
          Set the DefinitionsFactory implementation to use.
 void setPreparerFactoryClass(java.lang.Class<?> preparerFactoryClass)
          Set the PreparerFactory implementation to use.
 void setServletContext(javax.servlet.ServletContext servletContext)
           
 void setTilesProperties(java.util.Properties tilesProperties)
          Set Tiles properties (equivalent to the ServletContext init-params in the Tiles documentation), overriding the default settings.
 void setUseMutableTilesContainer(boolean useMutableTilesContainer)
          Set whether to use a MutableTilesContainer for this application.
 void setValidateDefinitions(boolean validateDefinitions)
          Set whether to validate the Tiles XML definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger
Constructor Detail

TilesConfigurer

public TilesConfigurer()
Method Detail

setDefinitions

public void setDefinitions(java.lang.String[] definitions)
Set the Tiles definitions, i.e. the list of files containing the definitions. Default is "/WEB-INF/tiles.xml".


setValidateDefinitions

public void setValidateDefinitions(boolean validateDefinitions)
Set whether to validate the Tiles XML definitions. Default is "true".


setDefinitionsFactoryClass

public void setDefinitionsFactoryClass(java.lang.Class<?> definitionsFactoryClass)
Set the DefinitionsFactory implementation to use. Default is UrlDefinitionsFactory, operating on definition resource URLs.

Specify a custom DefinitionsFactory, e.g. a UrlDefinitionsFactory subclass, to customize the creation of Tiles Definition objects. Note that such a DefinitionsFactory has to be able to handle URL source objects, unless you configure a different TilesContainerFactory.


setPreparerFactoryClass

public void setPreparerFactoryClass(java.lang.Class<?> preparerFactoryClass)
Set the PreparerFactory implementation to use. Default is BasicPreparerFactory , creating shared instances for specified preparer classes.

Specify SimpleSpringPreparerFactory to autowire ViewPreparer instances based on specified preparer classes, applying Spring's container callbacks as well as applying configured Spring BeanPostProcessors. If Spring's context-wide annotation-config has been activated, annotations in ViewPreparer classes will be automatically detected and applied.

Specify SpringBeanPreparerFactory to operate on specified preparer names instead of classes, obtaining the corresponding Spring bean from the DispatcherServlet's application context. The full bean creation process will be in the control of the Spring application context in this case, allowing for the use of scoped beans etc. Note that you need to define one Spring bean definition per preparer name (as used in your Tiles definitions).

See Also:
SimpleSpringPreparerFactory, SpringBeanPreparerFactory

setUseMutableTilesContainer

public void setUseMutableTilesContainer(boolean useMutableTilesContainer)
Set whether to use a MutableTilesContainer for this application. Default is "false".


setTilesProperties

public void setTilesProperties(java.util.Properties tilesProperties)
Set Tiles properties (equivalent to the ServletContext init-params in the Tiles documentation), overriding the default settings.


setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Specified by:
setServletContext in interface org.springframework.web.context.ServletContextAware

afterPropertiesSet

public void afterPropertiesSet()
                        throws org.apache.tiles.TilesException
Creates and exposes a TilesContainer for this web application.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
org.apache.tiles.TilesException - in case of setup failure

createTilesContainer

protected org.apache.tiles.TilesContainer createTilesContainer()
                                                        throws org.apache.tiles.TilesException
Create a TilesContainer for this web application.

Parameters:
context - this web application's ServletContext
Returns:
the TilesContainer to expose
Throws:
org.apache.tiles.TilesException - in case of setup failure

destroy

public void destroy()
             throws org.apache.tiles.TilesException
Removes the TilesContainer from this web application.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
org.apache.tiles.TilesException - in case of cleanup failure


Copyright © 2009-2010 DuraSpace. All Rights Reserved.