From afef4d70286054f230c54de964ec2211364596d4 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 1 Mar 2021 16:09:35 +0000 Subject: [PATCH 01/10] Upgrade dependencies --- booking-faces/pom.xml | 2 -- .../samples/booking/HotelLazyDataModel.java | 6 ++-- .../flows/booking/enterBookingDetails.xhtml | 4 +-- booking-mvc/pom.xml | 3 -- pom.xml | 30 +++++++++++-------- primefaces-showcase/pom.xml | 3 -- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/booking-faces/pom.xml b/booking-faces/pom.xml index b2156b1..768ff16 100644 --- a/booking-faces/pom.xml +++ b/booking-faces/pom.xml @@ -36,12 +36,10 @@ org.springframework.security spring-security-web - ${spring-security.version} org.springframework.security spring-security-config - ${spring-security.version} diff --git a/booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java b/booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java index 03b94c0..7c07ddc 100644 --- a/booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java +++ b/booking-faces/src/main/java/org/springframework/webflow/samples/booking/HotelLazyDataModel.java @@ -3,8 +3,10 @@ import java.util.List; import java.util.Map; +import org.primefaces.model.FilterMeta; import org.primefaces.model.LazyDataModel; import org.primefaces.model.SortOrder; + import org.springframework.beans.factory.annotation.Autowired; public class HotelLazyDataModel extends LazyDataModel { @@ -30,7 +32,7 @@ public void setSearchCriteria(SearchCriteria searchCriteria) { } @Override - public List load(int first, int pageSize, String sortField, SortOrder order, Map filters) { + public List load(int first, int pageSize, String sortField, SortOrder order, Map filterBy) { this.searchCriteria.setCurrentPage(first / pageSize + 1); this.hotels = bookingService.findHotels(searchCriteria, first, sortField, order.equals(SortOrder.ASCENDING)); return hotels; @@ -39,7 +41,7 @@ public List load(int first, int pageSize, String sortField, SortOrder ord @Override public Hotel getRowData(String rowKey) { for (Hotel hotel : this.hotels){ - if (hotel.getId().equals(rowKey)) { + if (hotel.getId().equals(Long.valueOf(rowKey))) { return hotel; } } diff --git a/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml b/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml index b439c83..10ef102 100644 --- a/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml +++ b/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml @@ -42,7 +42,7 @@

+ value="#{booking.checkinDate}" pattern="MM-dd-yyyy" required="true" />

@@ -51,7 +51,7 @@

+ value="#{booking.checkoutDate}" pattern="MM-dd-yyyy" required="true" />

diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index 9c92a65..23b34aa 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -41,17 +41,14 @@ org.springframework.security spring-security-web - ${spring-security.version} org.springframework.security spring-security-taglibs - ${spring-security.version} org.springframework.security spring-security-config - ${spring-security.version} diff --git a/pom.xml b/pom.xml index 6d86770..00e0c97 100644 --- a/pom.xml +++ b/pom.xml @@ -17,18 +17,17 @@ 3.4 - 2.4.0 - 5.2.12.Final - 6.0.7.Final + 2.5.1 + 5.4.28.Final + 6.2.0.Final 2.2.3 - 9.4.8.v20171121 - 4.12 - 2.10.0 - 2.2.16 - 2.2.12 - 6.1 + 9.4.38.v20210224 + 4.13.2 + 2.14.0 + 2.2.20 + 2.3.8 + 8.0 3.1.0 - 5.1.5.RELEASE 3.0.8 2.5.1.RELEASE @@ -38,14 +37,21 @@ org.springframework spring-framework-bom - 5.1.7.RELEASE + 5.3.4 pom import + + org.springframework.security + spring-security-bom + pom + import + 5.4.2 + org.slf4j slf4j-api - 1.7.25 + 1.7.30 diff --git a/primefaces-showcase/pom.xml b/primefaces-showcase/pom.xml index a71a88b..5cdf1a9 100644 --- a/primefaces-showcase/pom.xml +++ b/primefaces-showcase/pom.xml @@ -28,17 +28,14 @@ org.springframework.security spring-security-config - ${spring-security.version} org.springframework.security spring-security-web - ${spring-security.version} org.springframework.security spring-security-taglibs - ${spring-security.version} From 234897921e9d310aee184bede3e4d77a531113d1 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 28 Apr 2021 19:32:55 +0100 Subject: [PATCH 02/10] Upgrade commons-io and commons-fileupload --- primefaces-showcase/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primefaces-showcase/pom.xml b/primefaces-showcase/pom.xml index 5cdf1a9..0db4424 100644 --- a/primefaces-showcase/pom.xml +++ b/primefaces-showcase/pom.xml @@ -83,12 +83,12 @@ commons-fileupload commons-fileupload - 1.3.2 + [1.3.3,) commons-io commons-io - 2.5 + [2.7,) From 65a16fe70b98faa216536854e4122d9849b333bd Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Thu, 14 Jul 2022 16:47:48 +0100 Subject: [PATCH 03/10] Update dependencies --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 00e0c97..f2f943f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,10 +18,10 @@ 3.4 2.5.1 - 5.4.28.Final - 6.2.0.Final + 5.4.33.Final + 6.2.3.Final 2.2.3 - 9.4.38.v20210224 + 9.4.48.v20220622 4.13.2 2.14.0 2.2.20 @@ -37,7 +37,7 @@ org.springframework spring-framework-bom - 5.3.4 + 5.3.22 pom import @@ -46,7 +46,7 @@ spring-security-bom pom import - 5.4.2 + 5.6.6 org.slf4j From 2b42fa37360f5ba3e767ad55bd0e55d5ed4aaf63 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 15 Jul 2022 12:49:25 +0100 Subject: [PATCH 04/10] Switch to Web Flow 3.0 Upgrade to Spring Framework 6 and change package imports from servlet to jakarta. Not yet working as there is no Tiles anymore. --- booking-mvc/pom.xml | 78 +++++++------------ .../webflow/samples/booking/Booking.java | 22 +++--- .../samples/booking/BookingDateRange.java | 4 +- .../booking/BookingDateRangeValidator.java | 4 +- .../samples/booking/BookingFlowHandler.java | 4 +- .../webflow/samples/booking/Hotel.java | 8 +- .../samples/booking/JpaBookingService.java | 4 +- .../webflow/samples/booking/User.java | 6 +- .../booking/config/DataAccessConfig.java | 2 +- .../config/DispatcherServletInitializer.java | 2 +- .../SecurityWebApplicationInitializer.java | 1 + .../samples/booking/config/WebMvcConfig.java | 19 +---- booking-mvc/src/main/resources/log4j2.xml | 1 + pom.xml | 21 ++--- 14 files changed, 75 insertions(+), 101 deletions(-) diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index 23b34aa..ab30257 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -52,21 +52,21 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api ${servlet.version} provided - javax.servlet.jsp - jsp-api - 2.1 + jakarta.servlet.jsp + jakarta.servlet.jsp-api + ${jsp-api.version} provided - javax.servlet - jstl - 1.2 + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + ${jstl-api} @@ -76,50 +76,21 @@ org.thymeleaf - thymeleaf-spring4 - 2.1.5.RELEASE + thymeleaf-spring6 + 3.1.0.M1 org.thymeleaf.extras - thymeleaf-extras-tiles2-spring4 - 2.1.1.RELEASE - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity4 - 2.1.2.RELEASE + thymeleaf-extras-springsecurity6 + 3.1.0.M1 + - - org.apache.tiles - tiles-core - ${tiles.version} - - - org.apache.tiles - tiles-api - ${tiles.version} - - - org.apache.tiles - tiles-template - ${tiles.version} - - - org.apache.tiles - tiles-servlet - ${tiles.version} - - - org.apache.tiles - tiles-jsp - ${tiles.version} - + --> org.hsqldb @@ -127,14 +98,25 @@ ${hsqldb.version} runtime + + org.hibernate + hibernate-core-jakarta + ${hibernate.version} + org.hibernate hibernate-entitymanager ${hibernate.version} + + + org.hibernate + hibernate-core + + - org.hibernate + org.hibernate.validator hibernate-validator ${hibernate-validator.version} @@ -212,16 +194,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.10.1 - 1.8 - 1.8 + 17 + 17 org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 2.22.2 junit:junit diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java index dba0cf3..b13fc5d 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java @@ -7,17 +7,17 @@ import java.util.Date; import java.util.Set; -import javax.persistence.Basic; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import javax.validation.constraints.Future; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Basic; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.Transient; +import jakarta.validation.constraints.Future; +import jakarta.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java index a5cad18..f9d4708 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java @@ -5,8 +5,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; -import javax.validation.Payload; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; @Constraint(validatedBy = BookingDateRangeValidator.class) @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER }) diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java index 716a40b..ee7c133 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java @@ -1,7 +1,7 @@ package org.springframework.webflow.samples.booking; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; public class BookingDateRangeValidator implements ConstraintValidator { diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java index ae531e7..516e855 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java @@ -1,7 +1,7 @@ package org.springframework.webflow.samples.booking; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.webflow.core.FlowException; import org.springframework.webflow.execution.FlowExecutionOutcome; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java index 3bdad77..57ecd29 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java @@ -3,10 +3,10 @@ import java.io.Serializable; import java.math.BigDecimal; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; /** * A hotel where users may book stays. diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java index c05c76c..851026c 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java @@ -2,8 +2,8 @@ import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java index f0f6bae..f05e00a 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java @@ -2,9 +2,9 @@ import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * A user who can book hotels. diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java index 53166aa..22bd9b1 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java @@ -2,7 +2,7 @@ import java.util.Collections; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.context.annotation.Bean; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java index c86c1e0..a2749a2 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java @@ -1,6 +1,6 @@ package org.springframework.webflow.samples.booking.config; -import javax.servlet.Filter; +import jakarta.servlet.Filter; import org.springframework.web.filter.HiddenHttpMethodFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java index df49deb..f20d751 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java @@ -7,4 +7,5 @@ * the chain of Spring Security filters. */ public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { + } diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java index e5a3138..c2b9958 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java @@ -7,13 +7,11 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.tiles3.TilesConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.UrlBasedViewResolver; import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter; import org.springframework.webflow.mvc.servlet.FlowHandlerMapping; -import org.springframework.webflow.mvc.view.AjaxUrlBasedViewResolver; -import org.springframework.webflow.mvc.view.FlowAjaxTiles3View; import org.springframework.webflow.samples.booking.BookingFlowHandler; @EnableWebMvc @@ -62,17 +60,8 @@ public BookingFlowHandler BookingFlowHandler() { } @Bean - public AjaxUrlBasedViewResolver viewResolver() { - AjaxUrlBasedViewResolver resolver = new AjaxUrlBasedViewResolver(); - resolver.setViewClass(FlowAjaxTiles3View.class); - return resolver; - } - - @Bean - public TilesConfigurer tilesConfigurer() { - TilesConfigurer configurer = new TilesConfigurer(); - configurer.setDefinitions("/WEB-INF/**/views.xml"); - return configurer; + public UrlBasedViewResolver viewResolver() { + return new InternalResourceViewResolver(); } } diff --git a/booking-mvc/src/main/resources/log4j2.xml b/booking-mvc/src/main/resources/log4j2.xml index f495463..bb09f49 100644 --- a/booking-mvc/src/main/resources/log4j2.xml +++ b/booking-mvc/src/main/resources/log4j2.xml @@ -7,6 +7,7 @@ + diff --git a/pom.xml b/pom.xml index f2f943f..d11d3d5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,26 +10,29 @@ booking-mvc + 3.4 2.5.1 - 5.4.33.Final - 6.2.3.Final + 5.6.10.Final + 7.0.4.Final 2.2.3 - 9.4.48.v20220622 + 11.0.11 + 3.0.0 + 2.0.0 4.13.2 2.14.0 2.2.20 2.3.8 8.0 - 3.1.0 - 3.0.8 - 2.5.1.RELEASE + 5.0.0 + 3.0.0-SNAPSHOT @@ -37,7 +40,7 @@ org.springframework spring-framework-bom - 5.3.22 + 6.0.0-M5 pom import @@ -46,7 +49,7 @@ spring-security-bom pom import - 5.6.6 + 6.0.0-M5 org.slf4j @@ -56,7 +59,6 @@ - From 6f82ff3f3feb8e05abe5df1759630586d386cf89 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 15 Jul 2022 12:55:09 +0100 Subject: [PATCH 05/10] Switch from JSP to Thymeleaf views This is a revert of commit 758596 which did the opposite, "temporarily" while Thymeleaf support wasn't yet available. --- .../samples/booking/config/WebFlowConfig.java | 2 +- .../samples/booking/config/WebMvcConfig.java | 54 +++- .../hotels/booking/enterBookingDetails.html | 274 ++++++++++++++++++ .../hotels/booking/enterBookingDetails.jsp | 192 ------------ .../WEB-INF/hotels/booking/messages.html | 65 +++++ .../WEB-INF/hotels/booking/messages.jsp | 5 - .../WEB-INF/hotels/booking/reviewBooking.html | 135 +++++++++ .../WEB-INF/hotels/booking/reviewBooking.jsp | 63 ---- .../webapp/WEB-INF/hotels/booking/views.xml | 12 +- .../webapp/WEB-INF/hotels/bookingsTable.html | 96 ++++++ .../webapp/WEB-INF/hotels/bookingsTable.jsp | 53 ---- .../src/main/webapp/WEB-INF/hotels/list.html | 139 +++++++++ .../src/main/webapp/WEB-INF/hotels/list.jsp | 74 ----- .../main/webapp/WEB-INF/hotels/search.html | 68 +++++ .../src/main/webapp/WEB-INF/hotels/search.jsp | 10 - .../webapp/WEB-INF/hotels/searchForm.html | 95 ++++++ .../main/webapp/WEB-INF/hotels/searchForm.jsp | 35 --- .../src/main/webapp/WEB-INF/hotels/show.html | 81 ++++++ .../src/main/webapp/WEB-INF/hotels/show.jsp | 22 -- .../src/main/webapp/WEB-INF/hotels/views.xml | 10 +- .../src/main/webapp/WEB-INF/intro.html | 86 ++++++ booking-mvc/src/main/webapp/WEB-INF/intro.jsp | 29 -- .../main/webapp/WEB-INF/layouts/standard.html | 103 +++++++ .../main/webapp/WEB-INF/layouts/standard.jsp | 74 ----- .../src/main/webapp/WEB-INF/layouts/views.xml | 5 +- .../src/main/webapp/WEB-INF/login.html | 136 +++++++++ booking-mvc/src/main/webapp/WEB-INF/login.jsp | 65 ----- .../main/webapp/WEB-INF/logoutSuccess.html | 64 ++++ .../src/main/webapp/WEB-INF/logoutSuccess.jsp | 8 - booking-mvc/src/main/webapp/WEB-INF/views.xml | 6 +- 30 files changed, 1408 insertions(+), 653 deletions(-) create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/list.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/list.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/search.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/search.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/show.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/show.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/intro.html delete mode 100755 booking-mvc/src/main/webapp/WEB-INF/intro.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/layouts/standard.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/login.html delete mode 100755 booking-mvc/src/main/webapp/WEB-INF/login.jsp create mode 100644 booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html delete mode 100755 booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.jsp diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java index 4582cb2..2fe49a3 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java @@ -45,7 +45,7 @@ public FlowBuilderServices flowBuilderServices() { @Bean public MvcViewFactoryCreator mvcViewFactoryCreator() { MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator(); - factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.viewResolver())); + factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.tilesViewResolver())); factoryCreator.setUseSpringBeanBinding(true); return factoryCreator; } diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java index c2b9958..9c4980b 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java @@ -1,5 +1,8 @@ package org.springframework.webflow.samples.booking.config; +import java.util.LinkedHashSet; +import java.util.Set; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -7,16 +10,23 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.UrlBasedViewResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter; import org.springframework.webflow.mvc.servlet.FlowHandlerMapping; import org.springframework.webflow.samples.booking.BookingFlowHandler; +import org.thymeleaf.dialect.IDialect; +import org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect; +import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect; +import org.thymeleaf.extras.tiles2.dialect.TilesDialect; +import org.thymeleaf.extras.tiles2.spring4.web.configurer.ThymeleafTilesConfigurer; +import org.thymeleaf.extras.tiles2.spring4.web.view.FlowAjaxThymeleafTilesView; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.view.AjaxThymeleafViewResolver; +import org.thymeleaf.templateresolver.ServletContextTemplateResolver; @EnableWebMvc @Configuration -public class WebMvcConfig implements WebMvcConfigurer { +public class WebMvcConfig extends WebMvcConfigurerAdapter { @Autowired private WebFlowConfig webFlowConfig; @@ -60,8 +70,40 @@ public BookingFlowHandler BookingFlowHandler() { } @Bean - public UrlBasedViewResolver viewResolver() { - return new InternalResourceViewResolver(); + public AjaxThymeleafViewResolver tilesViewResolver() { + AjaxThymeleafViewResolver viewResolver = new AjaxThymeleafViewResolver(); + viewResolver.setViewClass(FlowAjaxThymeleafTilesView.class); + viewResolver.setTemplateEngine(templateEngine()); + return viewResolver; + } + + @Bean + public SpringTemplateEngine templateEngine(){ + + Set dialects = new LinkedHashSet(); + dialects.add(new TilesDialect()); + dialects.add(new SpringSecurityDialect()); + dialects.add(new ConditionalCommentsDialect()); + + SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + templateEngine.setAdditionalDialects(dialects); + return templateEngine; + } + + @Bean + public ServletContextTemplateResolver templateResolver() { + ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); + templateResolver.setPrefix("/WEB-INF"); + templateResolver.setTemplateMode("HTML5"); + return templateResolver; + } + + @Bean + public ThymeleafTilesConfigurer tilesConfigurer() { + ThymeleafTilesConfigurer configurer = new ThymeleafTilesConfigurer(); + configurer.setDefinitions("/WEB-INF/**/views.xml"); + return configurer; } } diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html new file mode 100644 index 0000000..83c00ef --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html @@ -0,0 +1,274 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +

The Herb Plaza

+ +
+ Thyme Square, 13 +
+ Icetown, + North Pole, + 0W +
+ Earth +
+ +

+ Nightly rate: 400.00 +

+ +
+ +
+ +
+ +
+ + Input is incorrect
+
+
+ +
+ Book Hotel +
+
+ +
+
+

+ + +
+
+
+
+ +
+
+

+ +
+
+
+
+ +
+
+

+ +

+
+
+
+
+ Smoking Preference: +
+
+

+ + +

+ +
+
+
+
+ Amenities: +
+
+

+ +
+ +
+ +

+ +
+
+
+
+ +
+
+

+ +
+
+
+
+ +
+
+

+ +
+
+
+
+ +
+
+

+ + +

+
+
+
+

+ + +

+ +
+
+ +
+ +
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.jsp deleted file mode 100644 index 413c5bb..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.jsp +++ /dev/null @@ -1,192 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -
-
-

${booking.hotel.name}

- -
- ${booking.hotel.address} -
- ${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip} -
- ${booking.hotel.country} -
-

- Nightly rate: ${status.value} -

-
-
- -
- - -
-
-
-
-
- -
- Book Hotel -
-
- -
-
-

- - -
-
-
-
- -
-
-

- -
-
-
-
- -
-
-

- - - - - -

-
-
-
-
- -
-
-

- - -

- -
-
-
-
- -
-
-

- - - -

- -
-
-
-
- -
-
-

- -
-
-
-
- -
-
-

- -
-
-
-
- -
-
-

- - - - - - - - - - - - - - - - - - - - - -

-
-
-
- - - -
-
-
-
-
diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html new file mode 100644 index 0000000..7d9638c --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html @@ -0,0 +1,65 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
    +
  • Input is incorrect
  • +
+
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.jsp deleted file mode 100644 index 42054c9..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.jsp +++ /dev/null @@ -1,5 +0,0 @@ -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -
- -
\ No newline at end of file diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html new file mode 100644 index 0000000..a54a00a --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html @@ -0,0 +1,135 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +

The Herb Plaza

+ +
+ Thyme Square, 13 +
+ Icetown, + North Pole, + 0W +
+ Earth +
+ +
+ +
+ +
+ +
+ + Confirm Booking Details + +
+
Check In:
+
+

2012-12-21

+
+
+
+
Checkout:
+
+

2012-12-21

+
+
+
+
Number of Nights:
+
+

0

+
+
+
+
Total Payment:
+
+

400.00

+
+
+
+
Credit Card #:
+
+

1234123412341234

+
+
+
+

+ + + +

+ +
+ +
+ +
+ +
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.jsp deleted file mode 100644 index bfed676..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.jsp +++ /dev/null @@ -1,63 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -
-
-

${booking.hotel.name}

- -
- ${booking.hotel.address} -
- ${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip} -
- ${booking.hotel.country} -
-
-
- -
- Confirm Booking Details -
-
Check In:
-
-

${status.value}

-
-
-
-
Checkout:
-
-

${status.value}

-
-
-
-
Number of Nights:
-
-

${status.value}

-
-
-
-
Total Payment:
-
-

${status.value}

-
-
-
-
Credit Card #:
-
-

${booking.creditCard}

-
-
-
- - - - -
-
-
-
- -
diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml index d5c5fd7..a085f66 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml @@ -2,15 +2,15 @@ - + - - + + - - - + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html new file mode 100644 index 0000000..d6bbc21 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html @@ -0,0 +1,96 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Current Hotel Bookings

+ +

+ No bookings found +

+ + + + + + + + + + + + + + + + + + + + + + + + +
NameAddressCity, StateCheck in DateCheck out DateConfirmation NumberAction
The Herb PlazaThyme Square, 13Icetown, North Pole2012-12-212012-12-211 +
+ +
+
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.jsp deleted file mode 100644 index 301b0ca..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.jsp +++ /dev/null @@ -1,53 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -
- -

Current Hotel Bookings

- - - - No bookings found - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameAddressCity, StateCheck in DateCheck out DateConfirmation NumberAction
${booking.hotel.name}${booking.hotel.address}${booking.hotel.city}, ${booking.hotel.state}${booking.checkinDate}${booking.checkoutDate}${booking.id} - - - - - - -
-
-
- -
\ No newline at end of file diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html new file mode 100644 index 0000000..45e8150 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html @@ -0,0 +1,139 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Hotel Results

+ +

+ Change Search + +

+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
NameAddressCity, StateZipAction
The Herb PlazaThyme Square, 13Icetown, North Pole, Earth0WView Hotel
No hotels found
+ +
+
+
+ Previous Results + +
+
+
+
+ More Results + +
+
+
+
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/list.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/list.jsp deleted file mode 100644 index 4955d40..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/list.jsp +++ /dev/null @@ -1,74 +0,0 @@ -<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> - -

Hotel Results

-

- Change Search - -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameAddressCity, StateZipAction
${hotel.name}${hotel.address}${hotel.city}, ${hotel.state}, ${hotel.country}${hotel.zip}View Hotel
No hotels found
-
-
- - << Prev - - -
-
- - Next >> - - -
-
-
-
- diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html new file mode 100644 index 0000000..35f5f0a --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ A search form will go here. See it at searchForm.html. +
+ +
+ A table with the current hotel bookings will go here. + See it at bookingsTable.html. +
+ + + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/search.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/search.jsp deleted file mode 100644 index ecc910b..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/search.jsp +++ /dev/null @@ -1,10 +0,0 @@ -<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - - - - -
${confirmed}
-
- - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html new file mode 100644 index 0000000..f337b8c --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html @@ -0,0 +1,95 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Search Hotels

+ +
+ +
    +
  • Input is incorrect
  • +
+ +
+
+ + + +
+
+
+ + +
+
+
+ +
+
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.jsp deleted file mode 100644 index 372baf7..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.jsp +++ /dev/null @@ -1,35 +0,0 @@ -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> -<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> - -

Search Hotels

- - - - - - -
-
- - -
-
-
- - - - - - -
-
-
- -
-
-
\ No newline at end of file diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html new file mode 100644 index 0000000..e4f6489 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html @@ -0,0 +1,81 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

The Herb Plaza

+ +
+ Thyme Square, 13 +
+ Icetown, + North Pole, + 0W +
+ Earth +
+ +
+

+ Nightly Rate: 4,300 +

+ +
+ +
+
+ + + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/show.jsp b/booking-mvc/src/main/webapp/WEB-INF/hotels/show.jsp deleted file mode 100644 index 82e2e70..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/show.jsp +++ /dev/null @@ -1,22 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -

${hotel.name}

-
- ${hotel.address} -
- ${hotel.city}, ${hotel.state}, ${hotel.zip} -
- ${hotel.country} -
-
-

- Nightly Rate: - ${status.value} -

- -
- -
-
diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml b/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml index ad0983d..a697ace 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml @@ -7,15 +7,15 @@ - - - + + + - - + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/intro.html b/booking-mvc/src/main/webapp/WEB-INF/intro.html new file mode 100644 index 0000000..f697b58 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/intro.html @@ -0,0 +1,86 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Welcome to Spring Travel

+

+ This sample demonstrates how to use Spring MVC and Spring Web Flow together with Thymeleaf and Tiles. +

+
+

+ The key features illustrated in this sample include: +

+
    +
  • A declarative navigation model enabling full browser button support and dynamic navigation rules
  • +
  • A fine-grained state management model, including support for ConversationScope and ViewScope
  • +
  • Modularization of web application functionality by domain use case, illustrating project structure best-practices
  • +
  • Spring Expression Language (SpEL) integration
  • +
  • Spring 3 formatting annotations @DateTimeFormat, @NumberFormat
  • +
  • Spring MVC custom namespace
  • +
  • Spring Security integration
  • +
  • Annotated POJO @Controllers for implementing RESTful user interactions.
  • +
  • Declarative page authoring with Thymeleaf and its Spring MVC's integration features.
  • +
  • Page layout and composition with Apache Tiles
  • +
  • A JavaScript API for decorating HTML elements with behaviors such as Ajax, validation, and effects.
  • +
  • A grid layout with Blueprint CSS
  • +
  • Exception handling support across all layers of the application
  • +
  • SpringSource Tool Suite integration, with support for graphical flow modeling and visualization
  • +
+

+ Start your Spring Travel experience +

+
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/intro.jsp b/booking-mvc/src/main/webapp/WEB-INF/intro.jsp deleted file mode 100755 index 4525d2f..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/intro.jsp +++ /dev/null @@ -1,29 +0,0 @@ -
-

Welcome to Spring Travel

-

- This sample demonstrates how to use Spring MVC and Spring Web Flow together with JavaServerPages (JSP) and Tiles. -

-
-

- The key features illustrated in this sample include: -

-
    -
  • A declarative navigation model enabling full browser button support and dynamic navigation rules
  • -
  • A fine-grained state management model, including support for ConversationScope and ViewScope
  • -
  • Modularization of web application functionality by domain use case, illustrating project structure best-practices
  • -
  • Spring Expression Language (SpEL) integration
  • -
  • Spring 3 formatting annotations @DateTimeFormat, @NumberFormat
  • -
  • Spring MVC custom namespace
  • -
  • Spring Security integration
  • -
  • Annotated POJO @Controllers for implementing RESTful user interactions.
  • -
  • Declarative page authoring with JSP, JSTL, and Spring MVC's form tag library
  • -
  • Page layout and composition with Apache Tiles
  • -
  • A JavaScript API for decorating HTML elements with behaviors such as Ajax, validation, and effects.
  • -
  • A grid layout with Blueprint CSS
  • -
  • Exception handling support across all layers of the application
  • -
  • SpringSource Tool Suite integration, with support for graphical flow modeling and visualization
  • -
-

- Start your Spring Travel experience -

-
diff --git a/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html b/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html new file mode 100644 index 0000000..fb1c2de --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html @@ -0,0 +1,103 @@ + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+

+ + generic hotel + +

+

+ + SpringOne 2GX + +

+
+
+ + + + + + + + BODY PAGE GOES HERE! + +
+
+ +
+ + + +
+ + \ No newline at end of file diff --git a/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.jsp b/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.jsp deleted file mode 100644 index 6eb31c3..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.jsp +++ /dev/null @@ -1,74 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> -<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %> - - - - - Spring Travel: Spring MVC and Web Flow Reference Application - " /> - " type="text/css" media="screen, projection" /> - " type="text/css" media="print" /> - - " type="text/css" media="screen" /> - - - - - -
- - -
- -
- - \ No newline at end of file diff --git a/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml b/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml index a5c7ddf..dac7eb1 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml +++ b/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml @@ -5,6 +5,7 @@ - - + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/login.html b/booking-mvc/src/main/webapp/WEB-INF/login.html new file mode 100644 index 0000000..d67df11 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/login.html @@ -0,0 +1,136 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Valid username/passwords are:

+
    +
  • keith/melbourne
  • +
  • erwin/leuven
  • +
  • jeremy/atlanta
  • +
  • scott/rochester
  • +
+
+ +
+ +
+ Your login attempt was not successful, try again.

+
+ +
+ +
+ + Login Information + +

+ +
+ +

+ + + +

+ +
+ +

+ + + +

+ + +

+ + + +

+ + +

+ +
+ +
+ +
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/login.jsp b/booking-mvc/src/main/webapp/WEB-INF/login.jsp deleted file mode 100755 index 76b082b..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/login.jsp +++ /dev/null @@ -1,65 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> - -
-

Valid username/passwords are:

-
    -
  • keith/melbourne
  • -
  • erwin/leuven
  • -
  • jeremy/atlanta
  • -
  • scott/rochester
  • -
-
- -
- -
- Your login attempt was not successful, try again. -
-
-
" method="post"> -
- Login Information -

- -
- -

- -

- -
- -

- -

- - -

- -
- -
-

- - -

-
-
-
diff --git a/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html b/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html new file mode 100644 index 0000000..b8552d5 --- /dev/null +++ b/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + Spring Travel: Spring MVC and Web Flow Reference Application + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Logout

+

You have successfully logged out.

+
+

Continue

+
+ + + + + + + + diff --git a/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.jsp b/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.jsp deleted file mode 100755 index 8f7418c..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.jsp +++ /dev/null @@ -1,8 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> - -
-

Logout

-

You have successfully logged out.

-
-

">Continue

-
diff --git a/booking-mvc/src/main/webapp/WEB-INF/views.xml b/booking-mvc/src/main/webapp/WEB-INF/views.xml index cc483c3..e1ffede 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/views.xml +++ b/booking-mvc/src/main/webapp/WEB-INF/views.xml @@ -6,15 +6,15 @@ - + - + - + From 6b958aad1e5c3f348fc27436dca74d96fb222700 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Mon, 18 Jul 2022 09:29:04 +0100 Subject: [PATCH 06/10] Add Thymeleaf ViewResolver for Web Flow The classes are copied from thymeleaf-spring5, temporarily here until they become available in thymeleaf-spring6. --- .../spring6/view/AjaxEnabledView.java | 82 ++++++++ .../spring6/view/AjaxThymeleafView.java | 144 +++++++++++++ .../view/AjaxThymeleafViewResolver.java | 192 ++++++++++++++++++ .../spring6/view/FlowAjaxThymeleafView.java | 93 +++++++++ 4 files changed, 511 insertions(+) create mode 100644 booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxEnabledView.java create mode 100644 booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafView.java create mode 100644 booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafViewResolver.java create mode 100644 booking-mvc/src/main/java/org/thymeleaf/spring6/view/FlowAjaxThymeleafView.java diff --git a/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxEnabledView.java b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxEnabledView.java new file mode 100644 index 0000000..0ca8b50 --- /dev/null +++ b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxEnabledView.java @@ -0,0 +1,82 @@ +/* + * ============================================================================= + * + * Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ +package org.thymeleaf.spring6.view; + +import org.springframework.web.servlet.View; +import org.springframework.webflow.context.servlet.AjaxHandler; + + +// Copied from thymeleaf-spring5. +// Temporarily here until available in thymeleaf-spring6. + + +/** + *

+ * Interface defining getter and setter methods for an + * {@code ajaxHandler} property in Views, so that they can + * be used in Spring AJAX environments. + *

+ * + * @author Daniel Fernández + * + * @since 3.0.3 + * + */ +public interface AjaxEnabledView extends View { + + + + /** + *

+ * Return the AJAX handler (from Spring Javascript) used + * to determine whether a request is an AJAX request or not. + *

+ *

+ * Views implementing this interface should be used with an instance of + * {@link AjaxThymeleafViewResolver} or any of its subclasses, + * so that {@link #setAjaxHandler(AjaxHandler)} can be called by + * the resolver when resolving the view, setting the default + * AJAX handler being used. + *

+ * + * @return the AJAX handler. + */ + public AjaxHandler getAjaxHandler(); + + + /** + *

+ * Sets the AJAX handler (from Spring Javascript) used + * to determine whether a request is an AJAX request or not. + *

+ *

+ * Views implementing this interface should be used with an instance of + * {@link AjaxThymeleafViewResolver} or any of its subclasses, + * so that this method can be called by + * the resolver when resolving the view, setting the default + * AJAX handler being used. + *

+ * + * @param ajaxHandler the AJAX handler. + */ + public void setAjaxHandler(final AjaxHandler ajaxHandler); + + +} \ No newline at end of file diff --git a/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafView.java b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafView.java new file mode 100644 index 0000000..2016db2 --- /dev/null +++ b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafView.java @@ -0,0 +1,144 @@ +/* + * ============================================================================= + * + * Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ +package org.thymeleaf.spring6.view; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; +import org.springframework.webflow.context.servlet.AjaxHandler; +import org.thymeleaf.exceptions.ConfigurationException; + + +// Copied from thymeleaf-spring5. +// Temporarily here until available in thymeleaf-spring6. + + +/** + *

+ * Subclass of {@link ThymeleafView} adding compatibility with AJAX events in + * Spring JavaScript (part of Spring WebFlow). This allows this View implementation + * to be able to return only fragments of the page. + *

+ *

+ * These rendering of fragments is used, for example, in Spring WebFlow's <render> + * instructions (though not only). + *

+ *

+ * This view searches for a comma-separated list of markup selectors in a request + * parameter called {@code fragments}. + *

+ * + * @author Daniel Fernández + * + * @since 3.0.3 + * + */ +public class AjaxThymeleafView extends ThymeleafView implements AjaxEnabledView { + + private static final Logger vlogger = LoggerFactory.getLogger(AjaxThymeleafView.class); + + private static final String FRAGMENTS_PARAM = "fragments"; + + + private AjaxHandler ajaxHandler = null; + + + + public AjaxThymeleafView() { + super(); + } + + + + public AjaxHandler getAjaxHandler() { + return this.ajaxHandler; + } + + + public void setAjaxHandler(final AjaxHandler ajaxHandler) { + this.ajaxHandler = ajaxHandler; + } + + + + + @Override + public void render(final Map model, final HttpServletRequest request, final HttpServletResponse response) + throws Exception { + + + final AjaxHandler templateAjaxHandler = getAjaxHandler(); + + if (templateAjaxHandler == null) { + throw new ConfigurationException("[THYMELEAF] AJAX Handler set into " + + AjaxThymeleafView.class.getSimpleName() + " instance for template " + + getTemplateName() + " is null."); + } + + if (templateAjaxHandler.isAjaxRequest(request, response)) { + + final Set fragmentsToRender = getRenderFragments(model, request, response); + if (fragmentsToRender == null || fragmentsToRender.size() == 0) { + vlogger.warn("[THYMELEAF] An Ajax request was detected, but no fragments were specified to be re-rendered. " + + "Falling back to full page render. This can cause unpredictable results when processing " + + "the ajax response on the client."); + super.render(model, request, response); + return; + } + + super.renderFragment(fragmentsToRender, model, request, response); + + } else { + + super.render(model, request, response); + + } + + } + + + + + @SuppressWarnings({ "rawtypes", "unused" }) + protected Set getRenderFragments( + final Map model, final HttpServletRequest request, final HttpServletResponse response) { + final String fragmentsParam = request.getParameter(FRAGMENTS_PARAM); + final String[] renderFragments = StringUtils.commaDelimitedListToStringArray(fragmentsParam); + if (renderFragments.length == 0) { + return null; + } + if (renderFragments.length == 1) { + return Collections.singleton(renderFragments[0]); + } + return new HashSet(Arrays.asList(renderFragments)); + } + + + +} \ No newline at end of file diff --git a/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafViewResolver.java b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafViewResolver.java new file mode 100644 index 0000000..c654551 --- /dev/null +++ b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/AjaxThymeleafViewResolver.java @@ -0,0 +1,192 @@ +/* + * ============================================================================= + * + * Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ +package org.thymeleaf.spring6.view; + +import java.io.IOException; +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.thymeleaf.exceptions.ConfigurationException; + +import org.springframework.web.servlet.View; +import org.springframework.web.servlet.view.RedirectView; +import org.springframework.webflow.context.servlet.AjaxHandler; +import org.springframework.webflow.context.servlet.DefaultAjaxHandler; + + +// Copied from thymeleaf-spring5. +// Temporarily here until available in thymeleaf-spring6. + + +/** + *

+ * Subclass of {@link ThymeleafViewResolver} adding compatibility with AJAX-based events + * (redirects) in Spring WebFlow. + *

+ *

+ * Important: Spring WebFlow dependencies are OPTIONAL. If you are not using WebFlow + * in your application, then you should be using {@link ThymeleafViewResolver} directly. + *

+ * + * @author Daniel Fernández + * + * @since 3.0.3 + * + */ +public class AjaxThymeleafViewResolver + extends ThymeleafViewResolver { + + + private static final Logger vrlogger = LoggerFactory.getLogger(AjaxThymeleafViewResolver.class); + + + private AjaxHandler ajaxHandler = new DefaultAjaxHandler(); + + + + public AjaxThymeleafViewResolver() { + super(); + } + + + /** + *

+ * Return the AJAX handler (from Spring Javascript) used + * to determine whether a request is an AJAX request or not + * in views resolved by this resolver. + *

+ *

+ * An instance of {@link DefaultAjaxHandler} is set by default. + *

+ * + * @return the AJAX handler. + */ + public AjaxHandler getAjaxHandler() { + return this.ajaxHandler; + } + + + /** + *

+ * Sets the AJAX handler (from Spring Javascript) used + * to determine whether a request is an AJAX request or not + * in views resolved by this resolver. + *

+ *

+ * An instance of {@link DefaultAjaxHandler} is set by default. + *

+ * + * @param ajaxHandler the AJAX handler. + */ + public void setAjaxHandler(final AjaxHandler ajaxHandler) { + this.ajaxHandler = ajaxHandler; + } + + + + + @Override + protected View createView(final String viewName, final Locale locale) throws Exception { + + if (!canHandle(viewName, locale)) { + return null; + } + + if (this.ajaxHandler == null) { + throw new ConfigurationException("[THYMELEAF] AJAX Handler set into " + + AjaxThymeleafViewResolver.class.getSimpleName() + " instance is null."); + } + + // Check for special "redirect:" prefix. + if (viewName.startsWith(REDIRECT_URL_PREFIX)) { + vrlogger.trace( + "[THYMELEAF] View {} is a redirect. An AJAX-enabled RedirectView implementation will " + + "be handling the request.", viewName); + final String redirectUrl = viewName.substring(REDIRECT_URL_PREFIX.length()); + return new AjaxRedirectView( + this.ajaxHandler, redirectUrl, isRedirectContextRelative(), isRedirectHttp10Compatible()); + } + + final View view = super.createView(viewName, locale); + + if (view instanceof AjaxEnabledView) { + // Set the AJAX handler into view, if it is an AjaxThymeleafView. + + final AjaxEnabledView ajaxEnabledView = (AjaxEnabledView) view; + + if (ajaxEnabledView.getAjaxHandler() == null && getAjaxHandler() != null) { + ajaxEnabledView.setAjaxHandler(getAjaxHandler()); + } + + } + + return view; + + } + + + + + + private static class AjaxRedirectView extends RedirectView { + + private static final Logger vlogger = LoggerFactory.getLogger(AjaxRedirectView.class); + + private AjaxHandler ajaxHandler = new DefaultAjaxHandler(); + + AjaxRedirectView(final AjaxHandler ajaxHandler, final String redirectUrl, + final boolean redirectContextRelative, final boolean redirectHttp10Compatible) { + super(redirectUrl, redirectContextRelative, redirectHttp10Compatible); + this.ajaxHandler = ajaxHandler; + } + + @Override + protected void sendRedirect(final HttpServletRequest request, final HttpServletResponse response, + final String targetUrl, final boolean http10Compatible) + throws IOException { + + if (this.ajaxHandler == null) { + throw new ConfigurationException("[THYMELEAF] AJAX Handler set into " + + AjaxThymeleafViewResolver.class.getSimpleName() + " instance is null."); + } + + if (this.ajaxHandler.isAjaxRequest(request, response)) { + if (vlogger.isTraceEnabled()) { + vlogger.trace( + "[THYMELEAF] RedirectView for URL \"{}\" is an AJAX request. AjaxHandler of class {} " + + "will be in charge of processing the request.", targetUrl, this.ajaxHandler.getClass().getName()); + } + this.ajaxHandler.sendAjaxRedirect(targetUrl, request, response, false); + } else { + vlogger.trace( + "[THYMELEAF] RedirectView for URL \"{}\" is not an AJAX request. Request will be handled " + + "as a normal redirect", targetUrl); + super.sendRedirect(request, response, targetUrl, http10Compatible); + } + } + + } + + + +} \ No newline at end of file diff --git a/booking-mvc/src/main/java/org/thymeleaf/spring6/view/FlowAjaxThymeleafView.java b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/FlowAjaxThymeleafView.java new file mode 100644 index 0000000..ed29e39 --- /dev/null +++ b/booking-mvc/src/main/java/org/thymeleaf/spring6/view/FlowAjaxThymeleafView.java @@ -0,0 +1,93 @@ +/* + * ============================================================================= + * + * Copyright (c) 2011-2018, The THYMELEAF team (http://www.thymeleaf.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============================================================================= + */ +package org.thymeleaf.spring6.view; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.webflow.execution.RequestContext; +import org.springframework.webflow.execution.RequestContextHolder; +import org.springframework.webflow.execution.View; + + +// Copied from thymeleaf-spring5. +// Temporarily here until available in thymeleaf-spring6. + + +/** + *

+ * Subclass of {@link AjaxThymeleafView} for Spring WebFlow, + * designed for obtaining the fragments to be rendered via + * AJAX in the way needed by Spring WebFlow. + *

+ *

+ * Most people will need to use this class instead of + * {@link AjaxThymeleafView} if you are using Spring WebFlow. + *

+ * + * @author Daniel Fernández + * + * @since 3.0.3 + * + */ +public class FlowAjaxThymeleafView extends AjaxThymeleafView { + + + + + + public FlowAjaxThymeleafView() { + super(); + } + + + + + + @Override + @SuppressWarnings("rawtypes") + protected Set getRenderFragments( + final Map model, final HttpServletRequest request, final HttpServletResponse response) { + + final RequestContext context = RequestContextHolder.getRequestContext(); + if (context == null) { + return super.getRenderFragments(model, request, response); + } + + final String[] fragments = (String[]) context.getFlashScope().get(View.RENDER_FRAGMENTS_ATTRIBUTE); + if (fragments == null || fragments.length == 0) { + return super.getRenderFragments(model, request, response); + } + if (fragments.length == 1) { + return Collections.singleton(fragments[0]); + } + return new HashSet(Arrays.asList(fragments)); + + } + + + +} \ No newline at end of file From 91a1866e618bd3a70bb1a622aaa8cdedd296cfa3 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Mon, 18 Jul 2022 09:31:19 +0100 Subject: [PATCH 07/10] Replace Tiles with Thymeleaf layout --- booking-mvc/pom.xml | 2 +- .../samples/booking/HotelsController.java | 2 +- .../booking/config/SecurityConfig.java | 3 +- .../samples/booking/config/WebFlowConfig.java | 2 +- .../samples/booking/config/WebMvcConfig.java | 58 ++++++++++--------- booking-mvc/src/main/resources/log4j2.xml | 1 + .../WEB-INF/hotels/booking/booking-flow.xml | 4 +- .../hotels/booking/enterBookingDetails.html | 45 +++++--------- .../WEB-INF/hotels/booking/messages.html | 47 ++++----------- .../WEB-INF/hotels/booking/reviewBooking.html | 50 +++++----------- .../webapp/WEB-INF/hotels/booking/views.xml | 16 ----- .../webapp/WEB-INF/hotels/bookingsTable.html | 33 ++--------- .../src/main/webapp/WEB-INF/hotels/list.html | 44 +++----------- .../main/webapp/WEB-INF/hotels/search.html | 37 +++--------- .../webapp/WEB-INF/hotels/searchForm.html | 31 +++------- .../src/main/webapp/WEB-INF/hotels/show.html | 49 +++++----------- .../src/main/webapp/WEB-INF/hotels/views.xml | 21 ------- .../src/main/webapp/WEB-INF/intro.html | 34 ++--------- .../main/webapp/WEB-INF/layouts/standard.html | 13 +---- .../src/main/webapp/WEB-INF/layouts/views.xml | 11 ---- .../src/main/webapp/WEB-INF/login.html | 44 +++++--------- .../main/webapp/WEB-INF/logoutSuccess.html | 47 +++++---------- booking-mvc/src/main/webapp/WEB-INF/views.xml | 20 ------- 23 files changed, 157 insertions(+), 457 deletions(-) delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml delete mode 100644 booking-mvc/src/main/webapp/WEB-INF/views.xml diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index ab30257..7c6f83e 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -72,7 +72,7 @@ org.thymeleaf thymeleaf - 2.1.5.RELEASE + 3.1.0.M1 org.thymeleaf diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/HotelsController.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/HotelsController.java index 5a11404..3e5da3c 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/HotelsController.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/HotelsController.java @@ -21,7 +21,7 @@ public HotelsController(BookingService bookingService) { } @GetMapping("/hotels/search") - public void search(SearchCriteria searchCriteria, Principal currentUser, Model model) { + public void search(@SuppressWarnings("unused") SearchCriteria searchCriteria, Principal currentUser, Model model) { if (currentUser != null) { List booking = bookingService.findBookings(currentUser.getName()); model.addAttribute(booking); diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityConfig.java index c31f82b..6d496b0 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityConfig.java @@ -5,6 +5,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @Configuration @EnableWebSecurity @@ -20,7 +21,7 @@ protected void configure(HttpSecurity http) throws Exception { .failureUrl("/login?login_error=1") .and() .logout() - .logoutUrl("/logout") + .logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET")) .logoutSuccessUrl("/logoutSuccess"); } diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java index 2fe49a3..31a979f 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebFlowConfig.java @@ -45,7 +45,7 @@ public FlowBuilderServices flowBuilderServices() { @Bean public MvcViewFactoryCreator mvcViewFactoryCreator() { MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator(); - factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.tilesViewResolver())); + factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.thymeleafViewResolver())); factoryCreator.setUseSpringBeanBinding(true); return factoryCreator; } diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java index 9c4980b..4851e13 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java @@ -3,34 +3,43 @@ import java.util.LinkedHashSet; import java.util.Set; +import jakarta.servlet.ServletContext; +import org.thymeleaf.dialect.IDialect; +import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect; +import org.thymeleaf.spring6.SpringTemplateEngine; +import org.thymeleaf.spring6.view.AjaxThymeleafViewResolver; +import org.thymeleaf.spring6.view.FlowAjaxThymeleafView; +import org.thymeleaf.templateresolver.WebApplicationTemplateResolver; +import org.thymeleaf.web.IWebApplication; +import org.thymeleaf.web.servlet.JakartaServletWebApplication; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.context.ServletContextAware; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter; import org.springframework.webflow.mvc.servlet.FlowHandlerMapping; import org.springframework.webflow.samples.booking.BookingFlowHandler; -import org.thymeleaf.dialect.IDialect; -import org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect; -import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect; -import org.thymeleaf.extras.tiles2.dialect.TilesDialect; -import org.thymeleaf.extras.tiles2.spring4.web.configurer.ThymeleafTilesConfigurer; -import org.thymeleaf.extras.tiles2.spring4.web.view.FlowAjaxThymeleafTilesView; -import org.thymeleaf.spring4.SpringTemplateEngine; -import org.thymeleaf.spring4.view.AjaxThymeleafViewResolver; -import org.thymeleaf.templateresolver.ServletContextTemplateResolver; @EnableWebMvc @Configuration -public class WebMvcConfig extends WebMvcConfigurerAdapter { +public class WebMvcConfig implements WebMvcConfigurer, ServletContextAware { @Autowired private WebFlowConfig webFlowConfig; + private ServletContext servletContext; + + @Override + public void setServletContext(ServletContext servletContext) { + this.servletContext = servletContext; + } + @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**").addResourceLocations("/", "classpath:/META-INF/web-resources/"); @@ -70,9 +79,9 @@ public BookingFlowHandler BookingFlowHandler() { } @Bean - public AjaxThymeleafViewResolver tilesViewResolver() { + public AjaxThymeleafViewResolver thymeleafViewResolver() { AjaxThymeleafViewResolver viewResolver = new AjaxThymeleafViewResolver(); - viewResolver.setViewClass(FlowAjaxThymeleafTilesView.class); + viewResolver.setViewClass(FlowAjaxThymeleafView.class); viewResolver.setTemplateEngine(templateEngine()); return viewResolver; } @@ -80,10 +89,8 @@ public AjaxThymeleafViewResolver tilesViewResolver() { @Bean public SpringTemplateEngine templateEngine(){ - Set dialects = new LinkedHashSet(); - dialects.add(new TilesDialect()); + Set dialects = new LinkedHashSet<>(); dialects.add(new SpringSecurityDialect()); - dialects.add(new ConditionalCommentsDialect()); SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.setTemplateResolver(templateResolver()); @@ -92,18 +99,13 @@ public SpringTemplateEngine templateEngine(){ } @Bean - public ServletContextTemplateResolver templateResolver() { - ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(); - templateResolver.setPrefix("/WEB-INF"); - templateResolver.setTemplateMode("HTML5"); - return templateResolver; - } - - @Bean - public ThymeleafTilesConfigurer tilesConfigurer() { - ThymeleafTilesConfigurer configurer = new ThymeleafTilesConfigurer(); - configurer.setDefinitions("/WEB-INF/**/views.xml"); - return configurer; + public WebApplicationTemplateResolver templateResolver() { + IWebApplication application = JakartaServletWebApplication.buildApplication(this.servletContext); + WebApplicationTemplateResolver resolver = new WebApplicationTemplateResolver(application); + resolver.setPrefix("/WEB-INF/"); + resolver.setSuffix(".html"); + resolver.setTemplateMode("HTML5"); + return resolver; } } diff --git a/booking-mvc/src/main/resources/log4j2.xml b/booking-mvc/src/main/resources/log4j2.xml index bb09f49..22aa0ba 100644 --- a/booking-mvc/src/main/resources/log4j2.xml +++ b/booking-mvc/src/main/resources/log4j2.xml @@ -8,6 +8,7 @@ + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml index d166884..be94c71 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml @@ -13,7 +13,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html index 83c00ef..db4f37d 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/enterBookingDetails.html @@ -1,55 +1,36 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - - + - - - - - - - + + -
+
diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html index 7d9638c..c1064d8 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/messages.html @@ -1,53 +1,33 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - - - - - - - - - - + + +
@@ -58,8 +38,5 @@ - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html index a54a00a..ef39373 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/reviewBooking.html @@ -1,55 +1,35 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - - - - - - - - - - + + + -
+
@@ -126,10 +106,6 @@

The Herb Plaza

- - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml b/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml deleted file mode 100644 index a085f66..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/views.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html index d6bbc21..abfd1ce 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/bookingsTable.html @@ -1,16 +1,13 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application @@ -26,29 +23,15 @@ - - - - - - - - - + + - - - - - - - + -
+

Current Hotel Bookings

@@ -87,10 +70,6 @@

Current Hotel Bookings

- - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html index 45e8150..d60087e 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/list.html @@ -1,16 +1,12 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application @@ -26,28 +22,14 @@ - - - - - - - - + - - - - - - - - + +

Hotel Results

@@ -55,14 +37,12 @@

Hotel Results

Change Search

@@ -100,13 +80,11 @@

Hotel Results

Previous Results
@@ -115,13 +93,11 @@

Hotel Results

More Results
@@ -130,10 +106,8 @@

Hotel Results

+
- - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html index 35f5f0a..a1cc521 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/search.html @@ -1,16 +1,12 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application @@ -27,42 +23,25 @@ href="../../styles/blueprint/ie.css" /> - + - - - - - - - - - - - - - - - + +
-
+
A search form will go here. See it at searchForm.html.
-
+
A table with the current hotel bookings will go here. See it at bookingsTable.html.
- +
- - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html index f337b8c..249c313 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/searchForm.html @@ -5,12 +5,10 @@ xmlns:sec="http://www.thymeleaf.org" lang="en"> - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application @@ -26,27 +24,14 @@ - - - - - - - - - + + - - - - - - - + +

Search Hotels

@@ -86,10 +71,8 @@

Search Hotels

+
- - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html b/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html index e4f6489..421e05e 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html +++ b/booking-mvc/src/main/webapp/WEB-INF/hotels/show.html @@ -5,49 +5,33 @@ xmlns:sec="http://www.thymeleaf.org" lang="en"> - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - - - - - - - - - - + + + + +

The Herb Plaza

@@ -71,11 +55,8 @@

The Herb Plaza

- +
- - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml b/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml deleted file mode 100644 index a697ace..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/hotels/views.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/intro.html b/booking-mvc/src/main/webapp/WEB-INF/intro.html index f697b58..233e1a4 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/intro.html +++ b/booking-mvc/src/main/webapp/WEB-INF/intro.html @@ -1,16 +1,12 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application @@ -23,31 +19,17 @@ href="../styles/blueprint/print.css" /> - + - - - - - - - - - - - - - - + -
+

Welcome to Spring Travel

This sample demonstrates how to use Spring MVC and Spring Web Flow together with Thymeleaf and Tiles. @@ -77,10 +59,6 @@

Welcome to Spring Travel

- - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html b/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html index fb1c2de..8706d91 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html +++ b/booking-mvc/src/main/webapp/WEB-INF/layouts/standard.html @@ -1,7 +1,6 @@ @@ -41,7 +40,7 @@ - +
@@ -77,16 +76,10 @@

-
+
- - - - - - BODY PAGE GOES HERE! - +
diff --git a/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml b/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml deleted file mode 100644 index dac7eb1..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/layouts/views.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/login.html b/booking-mvc/src/main/webapp/WEB-INF/login.html index d67df11..9f8b5c7 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/login.html +++ b/booking-mvc/src/main/webapp/WEB-INF/login.html @@ -1,52 +1,35 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - + + - - - - - - - + +

Valid username/passwords are:

@@ -127,6 +110,7 @@
+
diff --git a/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html b/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html index b8552d5..00f4f08 100644 --- a/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html +++ b/booking-mvc/src/main/webapp/WEB-INF/logoutSuccess.html @@ -2,53 +2,35 @@ - + - - - + Spring Travel: Spring MVC and Web Flow Reference Application - - - - - + - - - - - - - - - - + - - - - - - - + + -
+

Logout

You have successfully logged out.


@@ -57,8 +39,5 @@

Logout

- - - diff --git a/booking-mvc/src/main/webapp/WEB-INF/views.xml b/booking-mvc/src/main/webapp/WEB-INF/views.xml deleted file mode 100644 index e1ffede..0000000 --- a/booking-mvc/src/main/webapp/WEB-INF/views.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - From 83903575a95c5d27167589b39114e09a8625d5ab Mon Sep 17 00:00:00 2001 From: "jardel.novaes" Date: Fri, 10 Jun 2022 13:03:09 -0300 Subject: [PATCH 08/10] Use property for maven-surefure-pugin Closes gh-62 --- booking-faces/pom.xml | 2 +- booking-mvc/pom.xml | 2 +- pom.xml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/booking-faces/pom.xml b/booking-faces/pom.xml index 768ff16..4882f67 100644 --- a/booking-faces/pom.xml +++ b/booking-faces/pom.xml @@ -164,7 +164,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + ${maven-surefire-plugin.version} junit:junit diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index 7c6f83e..57cb130 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -203,7 +203,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + ${maven-surefire-plugin.version} junit:junit diff --git a/pom.xml b/pom.xml index d11d3d5..b8626db 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ 8.0 5.0.0 3.0.0-SNAPSHOT + 2.22.2 From b6ea43d82841f9721114705fd72f20f1b920a63b Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 1 Aug 2022 11:29:40 +0300 Subject: [PATCH 09/10] Fix failing tests --- .../webflow/samples/booking/BookingFlowExecutionTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/booking-mvc/src/test/java/org/springframework/webflow/samples/booking/BookingFlowExecutionTests.java b/booking-mvc/src/test/java/org/springframework/webflow/samples/booking/BookingFlowExecutionTests.java index 63d78e9..b371457 100644 --- a/booking-mvc/src/test/java/org/springframework/webflow/samples/booking/BookingFlowExecutionTests.java +++ b/booking-mvc/src/test/java/org/springframework/webflow/samples/booking/BookingFlowExecutionTests.java @@ -41,7 +41,7 @@ public void testStartBookingFlow() { startFlow(input, context); assertCurrentStateEquals("enterBookingDetails"); - assertResponseWrittenEquals("enterBookingDetails", context); + assertResponseWrittenEquals("/hotels/booking/enterBookingDetails.html", context); assertTrue(getRequiredFlowAttribute("booking") instanceof Booking); EasyMock.verify(bookingService); @@ -56,7 +56,7 @@ public void testEnterBookingDetails_Proceed() { resumeFlow(context); assertCurrentStateEquals("reviewBooking"); - assertResponseWrittenEquals("reviewBooking", context); + assertResponseWrittenEquals("/hotels/booking/reviewBooking.html", context); } public void testReviewBooking_Confirm() { From 11191e434aacda651b7b654296f42282ea6e5ead Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 9 Aug 2022 10:06:49 +0300 Subject: [PATCH 10/10] Upgrade to Web Flow 3.0.0-M1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b8626db..98d32f0 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ 2.3.8 8.0 5.0.0 - 3.0.0-SNAPSHOT + 3.0.0-M1 2.22.2