Thymeleaf-ied layout and several JSP pages.

This commit is contained in:
Daniel Fernández
2012-12-19 20:55:03 +01:00
committed by Rossen Stoyanchev
parent d00d53793e
commit 72402f6f2d
8 changed files with 74 additions and 42 deletions

View File

@@ -7,7 +7,7 @@
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- Configure Spring Security -->
<security:http auto-config="true">
<security:http auto-config="true" use-expressions="true">
<security:form-login login-page="/login" login-processing-url="/loginProcess"
default-target-url="/hotels/search" authentication-failure-url="/login?login_error=1" />
<security:logout logout-url="/logout" logout-success-url="/logoutSuccess" />
@@ -34,4 +34,4 @@
</security:authentication-provider>
</security:authentication-manager>
</beans>
</beans>

View File

@@ -0,0 +1,4 @@
<div tiles:include="searchForm"></div>
<div tiles:include="bookingsTable"></div>

View File

@@ -0,0 +1,35 @@
<h1>Search Hotels</h1>
<form action="#" th:object="${searchCriteria}" th:action="@{/hotels}" method="get" cssClass="inline">
<ul th:if="${#fields.hasErrors('*')}" class="errors span-18">
<li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
</ul>
<fieldset>
<div class="span-8">
<label for="searchString">Search String:</label>
<input type="text" id="searchString" th:field="*{searchString}" />
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "searchString",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { promptMessage : "Search hotels by name, address, city, or zip." }}));
</script>
</div>
<div class="span-6">
<div>
<label for="pageSize">Maximum results:</label>
<select id="pageSize" th:field="*{pageSize}">
<option label="5" value="5"/>
<option label="10" value="10"/>
<option label="20" value="20"/>
</select>
</div>
</div>
<div class="span-3 last">
<button type="submit">Find Hotels</button>
</div>
</fieldset>
</form>

View File

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

View File

@@ -1,10 +1,4 @@
<div xmlns:th="http://www.thymeleaf.org">
<!-- Following this, we will see a conditional comment! -->
<!--[if lt IE 8]>
<link rel="stylesheet" href="/resources/blueprint/ie.css" type="text/css" media="screen, projection">
<p>
<![endif]-->
<h1>Welcome to Spring Travel</h1>
<p>
This sample demonstrates how to use Spring MVC and Spring Web Flow together with JavaServerPages (JSP) and Tiles.

View File

@@ -1,17 +1,20 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xml:lang="en" lang="en">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org"
lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<link type="text/css" rel="stylesheet" href="#" th:href="@{/resources/dijit/themes/tundra/tundra.css}" />
<link rel="stylesheet" href="#" th:href="@{/resources/styles/blueprint/screen.css}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="#" th:href="@{/resources/styles/blueprint/print.css}" type="text/css" media="print" />
<link rel="stylesheet" href="../../styles/blueprint/screen.css" th:href="@{/resources/styles/blueprint/screen.css}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="../../styles/blueprint/print.css" th:href="@{/resources/styles/blueprint/print.css}" type="text/css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="<c:url value="/resources/blueprint/ie.css" />" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="../../styles/blueprint/ie.css" th:href="@{/resources/styles/blueprint/ie.css}" type="text/css" media="screen, projection" />
<![endif]-->
<link rel="stylesheet" href="#" th:href="@{/resources/styles/booking.css}" type="text/css" media="screen" />
<link rel="stylesheet" href="../../styles/booking.css" th:href="@{/resources/styles/booking.css}" type="text/css" media="screen" />
<script type="text/javascript" src="#" th:src="@{/resources/dojo/dojo.js}"></script>
<script type="text/javascript" src="#" th:src="@{/resources/spring/Spring.js}"></script>
<script type="text/javascript" src="#" th:src="@{/resources/spring/Spring-Dojo.js}"></script>
@@ -22,22 +25,18 @@
<div id="page" class="container">
<div id="header">
<div id="topbar">
<p>
<security:authorize ifAllGranted="ROLE_USER">
<c:if test="${pageContext.request.userPrincipal != null}">
Welcome, ${pageContext.request.userPrincipal.name} |
</c:if>
<a href="<c:url value="/logout" />">Logout</a>
</security:authorize>
<security:authorize ifAllGranted="ROLE_ANONYMOUS">
<a href="<c:url value="/login" />">Login</a>
</security:authorize>
<p sec:authorize="hasRole('ROLE_USER')" th:if="${#authentication}">
Welcome, <span sec:authentication="name">Dear User</span> |
<a href="#" th:href="@{/logout}">Logout</a>
</p>
<p sec:authorize="hasRole('ROLE_ANONYMOUS')">
<a href="#" th:href="@{/login}">Login</a>
</p>
</div>
<div id="logo">
<p>
<a href="<c:url value="/" />">
<img src="<c:url value="/resources/images/header.jpg"/>" alt="Spring Travel" />
<a href="#" th:href="@{/}">
<img src="../../images/header.jpg" th:src="@{/resources/images/header.jpg}" alt="Spring Travel" />
</a>
</p>
</div>
@@ -46,23 +45,23 @@
<div id="local" class="span-6">
<p>
<a href="http://www.thespringexperience.com">
<img src="<c:url value="/resources/images/diplomat.jpg"/>" alt="generic hotel" />
<img src="../../images/diplomat.jpg" th:src="@{/resources/images/diplomat.jpg}" alt="generic hotel" />
</a>
</p>
<p>
<a href="http://www.thespringexperience.com">
<img src="<c:url value="/resources/images/springone2gx.jpeg"/>" alt="SpringOne 2GX" />
<img src="../../images/springone2gx.jpeg" th:src="@{/resources/images/springone2gx.jpeg}" alt="SpringOne 2GX" />
</a>
</p>
</div>
<div id="main" class="span-18 last">
<tiles:insertAttribute name="body" />
<div id="main" class="span-18 last" tiles:include="body">
Body here...
</div>
</div>
<hr />
<div id="footer">
<a href="http://www.springframework.org">
<img src="<c:url value="/resources/images/powered-by-spring.png"/>" alt="Powered by Spring" />
<img src="../../images/powered-by-spring.png" th:src="@{/resources/images/powered-by-spring.png}" alt="Powered by Spring" />
</a>
</div>
</div>

View File

@@ -5,6 +5,6 @@
<tiles-definitions>
<definition name="standardLayout" template="/WEB-INF/layouts/standard.jsp" templateType="jsp"/>
<definition name="standardLayout" template="layouts/standard.html" templateType="thymeleaf"/>
</tiles-definitions>

View File

@@ -5,16 +5,16 @@
<tiles-definitions>
<definition name="intro" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="intro.html"/>
<definition name="intro" extends="standardLayout">
<put-attribute name="body" value="intro.html" type="thymeleaf"/>
</definition>
<definition name="login" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="login.html"/>
<definition name="login" extends="standardLayout">
<put-attribute name="body" value="login.html" type="thymeleaf"/>
</definition>
<definition name="logoutSuccess" extends="standardLayout" templateType="jsp">
<put-attribute name="body" value="logoutSuccess.html"/>
<definition name="logoutSuccess" extends="standardLayout">
<put-attribute name="body" value="logoutSuccess.html" type="thymeleaf"/>
</definition>
</tiles-definitions>