Applied Thymeleaf configuration

* Applied Thymeleaf configuration and Template Engine creation
    to webmvc-config configuration file.
  * Made application run through Thymeleaf's own Tiles infrastructure.
This commit is contained in:
Daniel Fernández
2012-09-13 01:06:12 +02:00
committed by Rossen Stoyanchev
parent c836b8f792
commit 7fec97b1d5
5 changed files with 57 additions and 21 deletions

View File

@@ -46,4 +46,40 @@
<!-- Custom FlowHandler for the hotel booking flow -->
<bean name="hotels/booking" class="org.springframework.webflow.samples.booking.BookingFlowHandler" />
<!-- Thymeleaf template resolver -->
<bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
<!-- Thymeleaf Template Engine -->
<bean id="templateEngine"
class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolver" ref="templateResolver" />
<property name="additionalDialects">
<set>
<bean class="org.thymeleaf.extras.tiles2.dialect.TilesDialect"/>
<bean class="org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect"/>
</set>
</property>
</bean>
<!-- Resolves logical view names returned by Controllers to Tiles; a view name to resolve is treated as the name of a tiles definition -->
<bean id="tilesViewResolver" class="org.thymeleaf.spring3.view.AjaxThymeleafViewResolver">
<property name="viewClass" value="org.thymeleaf.extras.tiles2.spring.web.view.FlowAjaxThymeleafTilesView"/>
<property name="templateEngine" ref="templateEngine"/>
</bean>
<!-- Configures the Tiles layout system using a specific thymeleaf-enabled Tiles Configurer -->
<bean id="tilesConfigurer" class="org.thymeleaf.extras.tiles2.spring.web.configurer.ThymeleafTilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/**/views.xml</value>
</list>
</property>
</bean>
</beans>

View File

@@ -5,12 +5,12 @@
<tiles-definitions>
<definition name="enterBookingDetails" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/booking/enterBookingDetails.jsp"/>
<definition name="enterBookingDetails" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/hotels/booking/enterBookingDetails.jsp" type="jsp"/>
</definition>
<definition name="reviewBooking" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/booking/reviewBooking.jsp" />
<definition name="reviewBooking" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/hotels/booking/reviewBooking.jsp" type="jsp"/>
</definition>
</tiles-definitions>

View File

@@ -5,17 +5,17 @@
<tiles-definitions>
<definition name="hotels/search" extends="standardLayout">
<definition name="hotels/search" extends="standardLayout" templateType="jsp">
<put-attribute name="body">
<definition template="/WEB-INF/hotels/search.jsp">
<put-attribute name="searchForm" value="/WEB-INF/hotels/searchForm.jsp" />
<put-attribute name="bookingsTable" value="/WEB-INF/hotels/bookingsTable.jsp" />
<definition template="/WEB-INF/hotels/search.jsp" templateType="jsp">
<put-attribute name="searchForm" value="/WEB-INF/hotels/searchForm.jsp" type="jsp"/>
<put-attribute name="bookingsTable" value="/WEB-INF/hotels/bookingsTable.jsp" type="jsp"/>
</definition>
</put-attribute>
</definition>
<definition name="hotels/*" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/{1}.jsp" />
<definition name="hotels/*" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/hotels/{1}.jsp" type="jsp"/>
</definition>
</tiles-definitions>

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="standardLayout" template="/WEB-INF/layouts/standard.jsp" />
<definition name="standardLayout" template="/WEB-INF/layouts/standard.jsp" templateType="jsp"/>
</tiles-definitions>

View File

@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="intro" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/intro.jsp" />
<definition name="intro" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/intro.jsp" type="jsp"/>
</definition>
<definition name="login" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/login.jsp" />
<definition name="login" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/login.jsp" type="jsp"/>
</definition>
<definition name="logoutSuccess" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/logoutSuccess.jsp" />
<definition name="logoutSuccess" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="/WEB-INF/logoutSuccess.jsp" type="jsp"/>
</definition>
</tiles-definitions>