Merge upgrade of booking-mvc to Web Flow 3

This commit is contained in:
rstoyanchev
2022-07-18 09:42:26 +01:00
50 changed files with 1742 additions and 802 deletions

View File

@@ -52,74 +52,45 @@
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>${jstl-api}</version>
</dependency>
<!-- Thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.5.RELEASE</version>
<version>3.1.0.M1</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
<version>2.1.5.RELEASE</version>
<artifactId>thymeleaf-spring6</artifactId>
<version>3.1.0.M1</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-tiles2-spring4</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>2.1.2.RELEASE</version>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
<version>3.1.0.M1</version>
</dependency>
<!--
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-conditionalcomments</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<!-- Apache Tiles -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>${tiles.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${tiles.version}</version>
</dependency>
-->
<!-- Database, JPA -->
<dependency>
<groupId>org.hsqldb</groupId>
@@ -127,14 +98,25 @@
<version>${hsqldb.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core-jakarta</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JSR 303 with Hibernate Validator -->
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
</dependency>
@@ -212,16 +194,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<version>2.22.2</version>
<configuration>
<junitArtifactName>junit:junit</junitArtifactName>
<includes>

View File

@@ -7,17 +7,17 @@ import java.util.Calendar;
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;

View File

@@ -5,8 +5,8 @@ import java.lang.annotation.Retention;
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 })

View File

@@ -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<BookingDateRange, Booking> {

View File

@@ -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;

View File

@@ -3,10 +3,10 @@ package org.springframework.webflow.samples.booking;
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.

View File

@@ -21,7 +21,7 @@ public class HotelsController {
}
@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> booking = bookingService.findBookings(currentUser.getName());
model.addAttribute(booking);

View File

@@ -2,8 +2,8 @@ package org.springframework.webflow.samples.booking;
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;

View File

@@ -2,9 +2,9 @@ package org.springframework.webflow.samples.booking;
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.

View File

@@ -2,7 +2,7 @@ package org.springframework.webflow.samples.booking.config;
import java.util.Collections;
import javax.persistence.EntityManagerFactory;
import jakarta.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;

View File

@@ -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;

View File

@@ -5,6 +5,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
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 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.failureUrl("/login?login_error=1")
.and()
.logout()
.logoutUrl("/logout")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET"))
.logoutSuccessUrl("/logoutSuccess");
}

View File

@@ -7,4 +7,5 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn
* the chain of Spring Security filters.
*/
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
}

View File

@@ -45,7 +45,7 @@ public class WebFlowConfig extends AbstractFlowConfiguration {
@Bean
public MvcViewFactoryCreator mvcViewFactoryCreator() {
MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.viewResolver()));
factoryCreator.setViewResolvers(Collections.singletonList(this.webMvcConfig.thymeleafViewResolver()));
factoryCreator.setUseSpringBeanBinding(true);
return factoryCreator;
}

View File

@@ -1,28 +1,45 @@
package org.springframework.webflow.samples.booking.config;
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.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
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
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
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/");
@@ -62,17 +79,33 @@ public class WebMvcConfig implements WebMvcConfigurer {
}
@Bean
public AjaxUrlBasedViewResolver viewResolver() {
AjaxUrlBasedViewResolver resolver = new AjaxUrlBasedViewResolver();
resolver.setViewClass(FlowAjaxTiles3View.class);
return resolver;
public AjaxThymeleafViewResolver thymeleafViewResolver() {
AjaxThymeleafViewResolver viewResolver = new AjaxThymeleafViewResolver();
viewResolver.setViewClass(FlowAjaxThymeleafView.class);
viewResolver.setTemplateEngine(templateEngine());
return viewResolver;
}
@Bean
public TilesConfigurer tilesConfigurer() {
TilesConfigurer configurer = new TilesConfigurer();
configurer.setDefinitions("/WEB-INF/**/views.xml");
return configurer;
public SpringTemplateEngine templateEngine(){
Set<IDialect> dialects = new LinkedHashSet<>();
dialects.add(new SpringSecurityDialect());
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.setAdditionalDialects(dialects);
return templateEngine;
}
@Bean
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;
}
}

View File

@@ -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.
/**
* <p>
* Interface defining getter and setter methods for an
* {@code ajaxHandler} property in Views, so that they can
* be used in Spring AJAX environments.
* </p>
*
* @author Daniel Fern&aacute;ndez
*
* @since 3.0.3
*
*/
public interface AjaxEnabledView extends View {
/**
* <p>
* Return the AJAX handler (from Spring Javascript) used
* to determine whether a request is an AJAX request or not.
* </p>
* <p>
* 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.
* </p>
*
* @return the AJAX handler.
*/
public AjaxHandler getAjaxHandler();
/**
* <p>
* Sets the AJAX handler (from Spring Javascript) used
* to determine whether a request is an AJAX request or not.
* </p>
* <p>
* 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.
* </p>
*
* @param ajaxHandler the AJAX handler.
*/
public void setAjaxHandler(final AjaxHandler ajaxHandler);
}

View File

@@ -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.
/**
* <p>
* 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 <i>fragments</i> of the page.
* </p>
* <p>
* These rendering of fragments is used, for example, in Spring WebFlow's &lt;render&gt;
* instructions (though not only).
* </p>
* <p>
* This view searches for a comma-separated list of <i>markup selectors</i> in a request
* parameter called {@code fragments}.
* </p>
*
* @author Daniel Fern&aacute;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<String, ?> 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<String> 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<String> 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<String>(Arrays.asList(renderFragments));
}
}

View File

@@ -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.
/**
* <p>
* Subclass of {@link ThymeleafViewResolver} adding compatibility with AJAX-based events
* (redirects) in Spring WebFlow.
* </p>
* <p>
* <b>Important</b>: Spring WebFlow dependencies are OPTIONAL. If you are not using WebFlow
* in your application, then you should be using {@link ThymeleafViewResolver} directly.
* </p>
*
* @author Daniel Fern&aacute;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();
}
/**
* <p>
* 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.
* </p>
* <p>
* An instance of {@link DefaultAjaxHandler} is set by default.
* </p>
*
* @return the AJAX handler.
*/
public AjaxHandler getAjaxHandler() {
return this.ajaxHandler;
}
/**
* <p>
* 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.
* </p>
* <p>
* An instance of {@link DefaultAjaxHandler} is set by default.
* </p>
*
* @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);
}
}
}
}

View File

@@ -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.
/**
* <p>
* Subclass of {@link AjaxThymeleafView} for Spring WebFlow,
* designed for obtaining the fragments to be rendered via
* AJAX in the way needed by Spring WebFlow.
* </p>
* <p>
* Most people will need to use this class instead of
* {@link AjaxThymeleafView} if you are using Spring WebFlow.
* </p>
*
* @author Daniel Fern&aacute;ndez
*
* @since 3.0.3
*
*/
public class FlowAjaxThymeleafView extends AjaxThymeleafView {
public FlowAjaxThymeleafView() {
super();
}
@Override
@SuppressWarnings("rawtypes")
protected Set<String> 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<String>(Arrays.asList(fragments));
}
}

View File

@@ -7,6 +7,8 @@
</Appenders>
<Loggers>
<Logger name="org.springframework.samples" level="debug" />
<Logger name="org.springframework.web" level="debug" />
<Logger name="org.thymeleaf.spring6" level="debug" />
<Root level="info">
<AppenderRef ref="Console" />
</Root>

View File

@@ -13,7 +13,7 @@
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
</on-start>
<view-state id="enterBookingDetails" model="booking">
<view-state id="enterBookingDetails" model="booking" view="/hotels/booking/enterBookingDetails.html">
<binder>
<binding property="checkinDate" />
<binding property="checkoutDate" />
@@ -32,7 +32,7 @@
<transition on="cancel" to="cancel" bind="false" />
</view-state>
<view-state id="reviewBooking">
<view-state id="reviewBooking" view="/hotels/booking/reviewBooking.html">
<on-render>
<render fragments="body" />
</on-render>

View File

@@ -0,0 +1,255 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<div class="span-5">
<h3 th:text="${booking.hotel.name}">The Herb Plaza</h3>
<address th:object="${booking.hotel}">
<span th:text="*{address}">Thyme Square, 13</span>
<br />
<span th:text="*{city}">Icetown</span>,
<span th:text="*{state}">North Pole</span>,
<span th:text="*{zip}">0W</span>
<br />
<span th:text="*{country}">Earth</span>
</address>
<p>
Nightly rate: <span th:text="${booking.hotel.price}">400.00</span>
</p>
</div>
<div class="span-12">
<form id="booking" action="#" th:object="${booking}" th:action="${flowExecutionUrl}" method="post">
<div class="error" th:if="${#fields.hasErrors('*')}">
<span th:each="err : ${#fields.errors('*')}">
<span th:text="${err}">Input is incorrect</span><br />
</span>
</div>
<fieldset>
<legend>Book Hotel</legend>
<div>
<div class="span-4">
<label for="checkinDate">Check In:</label>
</div>
<div class="span-7 last">
<p><input type="text" th:field="*{checkinDate}" /></p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "checkinDate",
widgetType : "dijit.form.DateTextBox",
widgetAttrs : { datePattern : "MM-dd-yyyy", required : true }}));
// ]]>
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="checkoutDate">Check Out:</label>
</div>
<div class="span-7 last">
<p><input type="text" th:field="*{checkoutDate}" /></p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "checkoutDate",
widgetType : "dijit.form.DateTextBox",
widgetAttrs : { datePattern : "MM-dd-yyyy", required : true }}));
// ]]>
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="beds">Room Preference:</label>
</div>
<div class="span-7 last">
<p>
<select th:field="*{beds}">
<option label="One king-size bed" value="1">One king-size bed</option>
<option label="Two double beds" value="2" >Two double beds</option>
<option label="Three beds" value="3" >Three beds</option>
</select>
</p>
</div>
</div>
<div>
<div class="label span-4">
Smoking Preference:
</div>
<div id="radio" class="span-7 last">
<p>
<input type="radio" id="smoking" th:field="*{smoking}" value="true" /><label for="smoking">Smoking</label>
<input type="radio" id="non-smoking" th:field="*{smoking}" value="false" /><label for="non-smoking">Non Smoking</label>
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : 'smoking',
widgetType : "dijit.form.RadioButton",
widgetModule : "dijit.form.CheckBox",
widgetAttrs : { value : "true" }
}));
Spring.addDecoration(new Spring.ElementDecoration({
elementId : 'non-smoking',
widgetType : "dijit.form.RadioButton",
widgetModule : "dijit.form.CheckBox",
widgetAttrs : { value : "false" }
}));
// ]]>
</script>
</div>
</div>
<div>
<div class="label span-4">
Amenities:
</div>
<div id="amenities" class="span-7 last">
<p>
<input type="checkbox" th:field="*{amenities}" value="OCEAN_VIEW" /><label th:for="${#ids.prev('amenities')}">Ocean View</label>
<br />
<input type="checkbox" th:field="*{amenities}" value="LATE_CHECKOUT" /><label th:for="${#ids.prev('amenities')}">Late Checkout</label>
<br />
<input type="checkbox" th:field="*{amenities}" value="MINIBAR" /><label th:for="${#ids.prev('amenities')}">Minibar</label>
</p>
<script type="text/javascript">
// <![CDATA[
dojo.query("#amenities input[type='checkbox']").forEach(function(element){
Spring.addDecoration(new Spring.ElementDecoration({
elementId: element.id,
widgetType : "dijit.form.CheckBox",
widgetAttrs : { checked : element.checked }
}));
});
// ]]>
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCard">Credit Card #:</label>
</div>
<div class="span-7 last">
<p><input type="text" th:field="*{creditCard}" /></p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "creditCard",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true, invalidMessage : "A 16-digit credit card number is required.",
regExp : "[0-9]{16}" }}));
// ]]>
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCardName">Credit Card Name:</label>
</div>
<div class="span-7 last">
<p><input type="text" th:field="*{creditCardName}" maxlength="40" /></p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "creditCardName",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true }}));
// ]]>
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCardExpiryMonth">Expiration Date:</label>
</div>
<div class="span-7 last">
<p>
<select th:field="*{creditCardExpiryMonth}">
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
<option value="7">Jul</option>
<option value="8">Aug</option>
<option value="9">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
<select th:field="*{creditCardExpiryYear}">
<option value="1">2008</option>
<option value="2">2009</option>
<option value="3">2010</option>
<option value="4">2011</option>
<option value="5">2012</option>
</select>
</p>
</div>
</div>
<div>
<p>
<button type="submit" id="proceed" name="_eventId_proceed">Proceed</button>
<button type="submit" name="_eventId_cancel" >Cancel</button>
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));
Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'proceed',event:'onclick',formId:'booking'}));
// ]]>
</script>
</div>
</fieldset>
</form>
</div>
</div>
</body>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- END of the content to be included in the execution result -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</html>

View File

@@ -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" %>
<div id="bookingForm">
<div class="span-5">
<h3>${booking.hotel.name}</h3>
<address>
${booking.hotel.address}
<br/>
${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip}
<br/>
${booking.hotel.country}
</address>
<p>
Nightly rate: <spring:bind path="booking.hotel.price">${status.value}</spring:bind>
</p>
</div>
<div class="span-12">
<spring:hasBindErrors name="booking">
<div class="error">
<spring:bind path="booking.*">
<c:forEach items="${status.errorMessages}" var="error">
<span><c:out value="${error}"/></span><br>
</c:forEach>
</spring:bind>
</div>
</spring:hasBindErrors>
<form:form modelAttribute="booking" action="${flowExecutionUrl}">
<fieldset>
<legend>Book Hotel</legend>
<div>
<div class="span-4">
<label for="checkinDate">Check In:</label>
</div>
<div class="last">
<p><form:input path="checkinDate"/></p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "checkinDate",
widgetType : "dijit.form.DateTextBox",
widgetAttrs : { datePattern : "MM-dd-yyyy", required : true }}));
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="checkoutDate">Check Out:</label>
</div>
<div class="last">
<p><form:input path="checkoutDate"/></p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "checkoutDate",
widgetType : "dijit.form.DateTextBox",
widgetAttrs : { datePattern : "MM-dd-yyyy", required : true }}));
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="beds">Room Preference:</label>
</div>
<div class="last">
<p>
<form:select id="beds" path="beds">
<form:option label="One king-size bed" value="1"/>
<form:option label="Two double beds" value="2"/>
<form:option label="Three beds" value="3"/>
</form:select>
</p>
</div>
</div>
<div>
<div class="label">
<label for="radio">Smoking Preference:</label>
</div>
<div id="radio">
<p>
<form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
<form:radiobutton id="non-smoking" path="smoking" label="Non Smoking" value="false"/>
</p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : 'smoking',
widgetType : "dijit.form.RadioButton",
widgetModule : "dijit.form.CheckBox",
widgetAttrs : { value : "true" }
}));
Spring.addDecoration(new Spring.ElementDecoration({
elementId : 'non-smoking',
widgetType : "dijit.form.RadioButton",
widgetModule : "dijit.form.CheckBox",
widgetAttrs : { value : "false" }
}));
</script>
</div>
</div>
<div>
<div>
<label for="amenities">Amenities:</label>
</div>
<div id="amenities">
<p>
<form:checkbox path="amenities" value="OCEAN_VIEW" label="Ocean View" />
<form:checkbox path="amenities" value="LATE_CHECKOUT" label="Late Checkout" />
<form:checkbox path="amenities" value="MINIBAR" label="Minibar" />
</p>
<script type="text/javascript">
dojo.query("#amenities input[type='checkbox']").forEach(function(element){
Spring.addDecoration(new Spring.ElementDecoration({
elementId: element.id,
widgetType : "dijit.form.CheckBox",
widgetAttrs : { checked : element.checked }
}));
});
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCard">Credit Card #:</label>
</div>
<div class="last">
<p><form:input path="creditCard"/></p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "creditCard",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true, invalidMessage : "A 16-digit credit card number is required.",
regExp : "[0-9]{16}" }}));
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCardName">Credit Card Name:</label>
</div>
<div class="last">
<p><form:input path="creditCardName" maxlength="40"/></p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "creditCardName",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true }}));
</script>
</div>
</div>
<div>
<div class="span-4">
<label for="creditCardExpiryMonth">Expiration Date:</label>
</div>
<div class="last">
<p>
<form:select id="creditCardExpiryMonth" path="creditCardExpiryMonth">
<form:option label="Jan" value="1"/>
<form:option label="Feb" value="2"/>
<form:option label="Mar" value="3"/>
<form:option label="Apr" value="4"/>
<form:option label="May" value="5"/>
<form:option label="Jun" value="6"/>
<form:option label="Jul" value="7"/>
<form:option label="Aug" value="8"/>
<form:option label="Sep" value="9"/>
<form:option label="Oct" value="10"/>
<form:option label="Nov" value="11"/>
<form:option label="Dec" value="12"/>
</form:select>
<form:select path="creditCardExpiryYear">
<form:option label="2008" value="1"/>
<form:option label="2009" value="2"/>
<form:option label="2010" value="3"/>
<form:option label="2011" value="4"/>
<form:option label="2012" value="5"/>
</form:select>
</p>
</div>
</div>
<div>
<button type="submit" id="proceed" name="_eventId_proceed">Proceed</button>
<button type="submit" name="_eventId_cancel" >Cancel</button>
<script type="text/javascript">
Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));
Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'proceed',event:'onclick',formId:'booking'}));
</script>
</div>
</fieldset>
</form:form>
</div>
</div>

View File

@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::#messages})">
<div id="messages">
<ul th:if="${#fields.hasErrors('*')}" class="errors">
<li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
</ul>
</div>
</body>
</html>

View File

@@ -1,5 +0,0 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<div id="messages">
<form:errors path="booking.*" cssClass="errors" />
</div>

View File

@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<div class="span-5">
<h3 th:text="${booking.hotel.name}">The Herb Plaza</h3>
<address th:object="${booking.hotel}">
<span th:text="*{address}">Thyme Square, 13</span>
<br />
<span th:text="*{city}">Icetown</span>,
<span th:text="*{state}">North Pole</span>,
<span th:text="*{zip}">0W</span>
<br />
<span th:text="*{country}">Earth</span>
</address>
</div>
<div class="span-12 last">
<form id="confirm" action="#" method="post" th:object="${booking}" th:action="${flowExecutionUrl}">
<fieldset>
<legend>Confirm Booking Details</legend>
<div>
<div class="span-3">Check In:</div>
<div class="span-8 last">
<p th:text="*{checkinDate}">2012-12-21</p>
</div>
</div>
<div>
<div class="span-3">Checkout:</div>
<div class="span-8 last">
<p th:text="*{checkoutDate}">2012-12-21</p>
</div>
</div>
<div>
<div class="span-3">Number of Nights:</div>
<div class="span-8 last">
<p th:text="*{nights}">0</p>
</div>
</div>
<div>
<div class="span-3">Total Payment:</div>
<div class="span-8 last">
<p th:text="*{total}">400.00</p>
</div>
</div>
<div>
<div class="span-3">Credit Card #:</div>
<div class="span-8 last">
<p th:text="*{creditCard}">1234123412341234</p>
</div>
</div>
<div>
<p>
<button type="submit" name="_eventId_confirm">Confirm</button>
<button type="submit" name="_eventId_revise" id="revise">Revise</button>
<button type="submit" name="_eventId_cancel">Cancel</button>
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'revise',event:'onclick',formId:'confirm'}));
// ]]>
</script>
</div>
</fieldset>
</form>
</div>
</div>
</body>
</html>

View File

@@ -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" %>
<div id="bookingForm">
<div class="span-5">
<h3>${booking.hotel.name}</h3>
<address>
${booking.hotel.address}
<br/>
${booking.hotel.city}, ${booking.hotel.state}, ${booking.hotel.zip}
<br/>
${booking.hotel.country}
</address>
</div>
<div class="span-12 last">
<form:form id="confirm" modelAttribute="booking" action="${flowExecutionUrl}">
<fieldset>
<legend>Confirm Booking Details</legend>
<div>
<div class="span-4">Check In:</div>
<div class="last">
<p><spring:bind path="checkinDate">${status.value}</spring:bind></p>
</div>
</div>
<div>
<div class="span-4">Checkout:</div>
<div class="last">
<p><spring:bind path="checkoutDate">${status.value}</spring:bind></p>
</div>
</div>
<div>
<div class="span-4">Number of Nights:</div>
<div class="last">
<p><spring:bind path="nights">${status.value}</spring:bind></p>
</div>
</div>
<div>
<div class="span-4">Total Payment:</div>
<div class="last">
<p><spring:bind path="total">${status.value}</spring:bind></p>
</div>
</div>
<div>
<div class="span-4">Credit Card #:</div>
<div class="last">
<p>${booking.creditCard}</p>
</div>
</div>
<div>
<button type="submit" name="_eventId_confirm">Confirm</button>
<button type="submit" name="_eventId_revise" id="revise">Revise</button>
<button type="submit" name="_eventId_cancel">Cancel</button>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'revise',event:'onclick',formId:'confirm'}));
</script>
</div>
</fieldset>
</form:form>
</div>
</div>

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"https://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="enterBookingDetails" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/booking/enterBookingDetails.jsp"/>
</definition>
<definition name="reviewBooking" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/booking/reviewBooking.jsp" />
</definition>
</tiles-definitions>

View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent" sec:authorize="hasRole('ROLE_USER')">
<h2>Current Hotel Bookings</h2>
<p th:unless="${bookingList}">
No bookings found
</p>
<table class="summary" th:if="${bookingList}">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City, State</th>
<th>Check in Date</th>
<th>Check out Date</th>
<th>Confirmation Number</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="booking : ${bookingList}" th:object="${booking}">
<td th:text="*{hotel.name}">The Herb Plaza</td>
<td th:text="*{hotel.address}">Thyme Square, 13</td>
<td th:text="*{hotel.city} + ', ' + *{hotel.state}">Icetown, North Pole</td>
<td th:text="*{checkinDate}">2012-12-21</td>
<td th:text="*{checkoutDate}">2012-12-21</td>
<td th:text="*{id}">1</td>
<td>
<form action="#" th:action="@{'/bookings/' + *{id}}" th:method="'delete'">
<button type="submit">Cancel</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

View File

@@ -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" %>
<div id="bookings">
<security:authorize access="hasRole('ROLE_USER')">
<h2>Current Hotel Bookings</h2>
<c:if test="${empty bookingList}">
<tr>
<td colspan="7">No bookings found</td>
</tr>
</c:if>
<c:if test="${!empty bookingList}">
<table class="summary">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City, State</th>
<th>Check in Date</th>
<th>Check out Date</th>
<th>Confirmation Number</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach var="booking" items="${bookingList}">
<tr>
<td>${booking.hotel.name}</td>
<td>${booking.hotel.address}</td>
<td>${booking.hotel.city}, ${booking.hotel.state}</td>
<td>${booking.checkinDate}</td>
<td>${booking.checkoutDate}</td>
<td>${booking.id}</td>
<td>
<spring:url var="bookingUrl" value="/bookings/{id}">
<spring:param name="id" value="${booking.id}"/>
</spring:url>
<form:form action="${bookingUrl}" method="delete">
<button type="submit">Cancel</button>
</form:form>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
</security:authorize>
</div>

View File

@@ -0,0 +1,113 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<h1>Hotel Results</h1>
<p>
<a id="changeSearchLink" href="#"
th:href="@{hotels/search(searchString=${searchCriteria.searchString},pageSize=${searchCriteria.pageSize})}">Change Search</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "changeSearchLink",
event: "onclick",
popup: true,
params: {fragments: "#searchForm"}
}));
</script>
</p>
<div id="hotelResults">
<div th:if="${hotelList}">
<table class="summary">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City, State</th>
<th>Zip</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="hotel : ${hotelList}">
<td th:text="${hotel.name}">The Herb Plaza</td>
<td th:text="${hotel.address}">Thyme Square, 13</td>
<td th:text="${hotel.city} + ', ' + ${hotel.state} + ', ' + ${hotel.country}">Icetown, North Pole, Earth</td>
<td th:text="${hotel.zip}">0W</td>
<td><a href="#" th:href="@{'hotels/' + ${hotel.id}}">View Hotel</a></td>
</tr>
<tr th:unless="${hotelList}">
<td colspan="5">No hotels found</td>
</tr>
</tbody>
</table>
<div class="buttonGroup">
<div class="span-3">
<div th:if="${searchCriteria.page > 0}">
<a id="prevResultsLink" href="#"
th:href="@{hotels(searchString=${searchCriteria.searchString},pageSize=${searchCriteria.pageSize},page=${searchCriteria.page - 1})}">Previous Results</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "prevResultsLink",
event: "onclick",
params: {fragments: "#hotelResults"}
}));
</script>
</div>
</div>
<div class="span-3 append-12 last">
<div th:if="${hotelList} and ${hotelList.size() == searchCriteria.pageSize}">
<a id="moreResultsLink" href="#"
th:href="@{hotels(searchString=${searchCriteria.searchString},pageSize=${searchCriteria.pageSize},page=${searchCriteria.page + 1})}">More Results</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "moreResultsLink",
event: "onclick",
params: {fragments: "#hotelResults"}
}));
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -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"%>
<h1>Hotel Results</h1>
<p>
<a id="changeSearchLink" href="hotels/search?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}">Change Search</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "changeSearchLink",
event: "onclick",
popup: true,
params: {fragments: "searchForm"}
}));
</script>
</p>
<div id="hotelResults">
<c:if test="${not empty hotelList}">
<table class="summary">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
<th>City, State</th>
<th>Zip</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach var="hotel" items="${hotelList}">
<tr>
<td>${hotel.name}</td>
<td>${hotel.address}</td>
<td>${hotel.city}, ${hotel.state}, ${hotel.country}</td>
<td>${hotel.zip}</td>
<td><a href="hotels/${hotel.id}">View Hotel</a></td>
</tr>
</c:forEach>
<c:if test="${empty hotelList}">
<tr>
<td colspan="5">No hotels found</td>
</tr>
</c:if>
</tbody>
</table>
<div class="buttonGroup">
<div class="span-3">
<c:if test="${searchCriteria.page > 0}">
<a id="prevResultsLink" href="hotels?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page - 1}"><< Prev</a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "prevResultsLink",
event: "onclick",
params: {fragments: "body"}
}));
</script>
</c:if>
</div>
<div class="span-3 append-12 last">
<c:if test="${not empty hotelList && fn:length(hotelList) == searchCriteria.pageSize}">
<a id="moreResultsLink" href="hotels?searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page + 1}">Next >></a>
<script type="text/javascript">
Spring.addDecoration(new Spring.AjaxEventDecoration({
elementId: "moreResultsLink",
event: "onclick",
params: {fragments: "body"}
}));
</script>
</c:if>
</div>
</div>
</c:if>
</div>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<div id="searchForm" th:replace="hotels/searchForm.html :: bodyContent">
A search form will go here. See it at <a href="searchForm.html">searchForm.html</a>.
</div>
<div th:replace="hotels/bookingsTable.html :: bodyContent">
A table with the current hotel bookings will go here.
See it at <a href="bookingsTable.html">bookingsTable.html</a>.
</div>
</div>
</body>
</html>

View File

@@ -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" %>
<tiles:insertAttribute name="searchForm" />
<c:if test="${not empty confirmed}">
<div class="confirmed">${confirmed}</div>
</c:if>
<tiles:insertAttribute name="bookingsTable" />

View File

@@ -0,0 +1,78 @@
<!DOCTYPE html>
<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 th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<h1>Search Hotels</h1>
<form action="#" th:object="${searchCriteria}" th:action="@{/hotels}" method="get" class="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">
// <![CDATA[
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>
</div>
</body>
</html>

View File

@@ -1,35 +0,0 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<h1>Search Hotels</h1>
<c:url var="hotelsUrl" value="/hotels"/>
<form:form modelAttribute="searchCriteria" action="${hotelsUrl}" method="get" cssClass="inline">
<span class="errors span-18">
<form:errors path="*"/>
</span>
<fieldset>
<div class="span-7">
<form:input id="searchString" path="searchString"/>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "searchString",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { promptMessage : "Name, address, city, or zip." }}));
</script>
</div>
<div class="span-6">
<div>
<label for="pageSize">Page Size:</label>
<form:select id="pageSize" path="pageSize">
<form:option label="5" value="5"/>
<form:option label="10" value="10"/>
<form:option label="20" value="20"/>
</form:select>
</div>
</div>
<div class="span-3 last">
<button type="submit">Find Hotels</button>
</div>
</fieldset>
</form:form>

View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<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 th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<h1 th:text="${hotel.name}">The Herb Plaza</h1>
<address th:object="${hotel}">
<span th:text="*{address}">Thyme Square, 13</span>
<br />
<span th:text="*{city}">Icetown</span>,
<span th:text="*{state}">North Pole</span>,
<span th:text="*{zip}">0W</span>
<br />
<span th:text="*{country}">Earth</span>
</address>
<form action="#" th:action="@{/hotels/booking(mode='embedded')}" method="get">
<p>
Nightly Rate: <span th:text="${hotel.price}">4,300</span>
</p>
<input type="hidden" name="hotelId" th:value="${hotel.id}" />
<div>
<button type="submit">Book Hotel</button>
</div>
</form>
</div>
</body>
</html>

View File

@@ -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" %>
<h1>${hotel.name}</h1>
<address>
${hotel.address}
<br />
${hotel.city}, ${hotel.state}, ${hotel.zip}
<br />
${hotel.country}
</address>
<form action="booking?mode=embedded" method="get">
<p>
Nightly Rate:
<spring:bind path="hotel.price">${status.value}</spring:bind>
</p>
<input type="hidden" name="hotelId" value="${hotel.id}" />
<div>
<button type="submit">Book Hotel</button>
</div>
</form>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"https://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="hotels/search" extends="standardLayout">
<put-attribute name="body">
<definition template="/WEB-INF/hotels/search.jsp">
<put-attribute name="searchForm" value="/WEB-INF/hotels/searchForm.jsp" />
<put-attribute name="bookingsTable" value="/WEB-INF/hotels/bookingsTable.jsp" />
</definition>
</put-attribute>
</definition>
<definition name="hotels/*" extends="standardLayout">
<put-attribute name="body" value="/WEB-INF/hotels/{1}.jsp" />
</definition>
</tiles-definitions>

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<h1>Welcome to Spring Travel</h1>
<p>
This sample demonstrates how to use Spring MVC and Spring Web Flow together with Thymeleaf and Tiles.
</p>
<hr />
<p>
The key features illustrated in this sample include:
</p>
<ul>
<li>A declarative navigation model enabling full browser button support and dynamic navigation rules</li>
<li>A fine-grained state management model, including support for ConversationScope and ViewScope</li>
<li>Modularization of web application functionality by domain use case, illustrating project structure best-practices</li>
<li>Spring Expression Language (SpEL) integration</li>
<li>Spring 3 formatting annotations @DateTimeFormat, @NumberFormat</li>
<li>Spring MVC custom namespace</li>
<li>Spring Security integration</li>
<li>Annotated POJO @Controllers for implementing RESTful user interactions.</li>
<li>Declarative page authoring with Thymeleaf and its Spring MVC's integration features.</li>
<li>Page layout and composition with Apache Tiles</li>
<li>A JavaScript API for decorating HTML elements with behaviors such as Ajax, validation, and effects.</li>
<li>A grid layout with Blueprint CSS</li>
<li>Exception handling support across all layers of the application</li>
<li>SpringSource Tool Suite integration, with support for graphical flow modeling and visualization</li>
</ul>
<p>
<a href="hotels/search.html" th:href="@{/hotels/search}">Start your Spring Travel experience</a>
</p>
</div>
</body>
</html>

View File

@@ -1,29 +0,0 @@
<div>
<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.
</p>
<hr/>
<p>
The key features illustrated in this sample include:
</p>
<ul>
<li>A declarative navigation model enabling full browser button support and dynamic navigation rules</li>
<li>A fine-grained state management model, including support for ConversationScope and ViewScope</li>
<li>Modularization of web application functionality by domain use case, illustrating project structure best-practices</li>
<li>Spring Expression Language (SpEL) integration</li>
<li>Spring 3 formatting annotations @DateTimeFormat, @NumberFormat</li>
<li>Spring MVC custom namespace</li>
<li>Spring Security integration</li>
<li>Annotated POJO @Controllers for implementing RESTful user interactions.</li>
<li>Declarative page authoring with JSP, JSTL, and Spring MVC's form tag library</li>
<li>Page layout and composition with Apache Tiles</li>
<li>A JavaScript API for decorating HTML elements with behaviors such as Ajax, validation, and effects.</li>
<li>A grid layout with Blueprint CSS</li>
<li>Exception handling support across all layers of the application</li>
<li>SpringSource Tool Suite integration, with support for graphical flow modeling and visualization</li>
</ul>
<p>
<a href="hotels/search">Start your Spring Travel experience</a>
</p>
</div>

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org"
lang="en">
<head>
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/screen.css"
th:href="@{/resources/styles/blueprint/screen.css}" />
<link rel="stylesheet" type="text/css" media="print"
href="../../styles/blueprint/print.css"
th:href="@{/resources/styles/blueprint/print.css}" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../../styles/blueprint/ie.css"
th:href="@{/resources/styles/blueprint/ie.css}" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen"
href="../../styles/booking.css"
th:href="@{/resources/styles/booking.css}" />
<!-- The following styles and scripts are served from spring-js-resources-{ver}.jar -->
<link rel="stylesheet" type="text/css"
href="#" th:href="@{/resources/dijit/themes/tundra/tundra.css}" />
<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>
</head>
<body class="tundra" th:fragment="body(bodyContent)">
<div id="page" class="container">
<div id="header">
<div id="topbar">
<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="#" th:href="@{/}">
<img src="../../images/header.jpg" th:src="@{/resources/images/header.jpg}" alt="Spring Travel" />
</a>
</p>
</div>
</div>
<div id="content">
<div id="local" class="span-6">
<p>
<a href="http://www.thespringexperience.com">
<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="../../images/springone2gx.jpeg" th:src="@{/resources/images/springone2gx.jpeg}" alt="SpringOne 2GX" />
</a>
</p>
</div>
<div id="main" class="span-18 last" th:insert="${bodyContent}">
BODY PAGE GOES HERE!
</div>
</div>
<hr />
<div id="footer">
<a href="http://www.springframework.org">
<img src="../../images/powered-by-spring.png" th:src="@{/resources/images/powered-by-spring.png}" alt="Powered by Spring" />
</a>
</div>
</div>
</body>
</html>

View File

@@ -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" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 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="<c:url value="/resources/dijit/themes/tundra/tundra.css" />" />
<link rel="stylesheet" href="<c:url value="/resources/styles/blueprint/screen.css" />" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="<c:url value="/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" />
<![endif]-->
<link rel="stylesheet" href="<c:url value="/resources/styles/booking.css" />" type="text/css" media="screen" />
<script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js" />"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js" />"></script>
</head>
<body class="tundra">
<div id="page" class="container">
<div id="header">
<div id="topbar">
<security:authorize access="hasRole('ROLE_USER')">
<form action="<c:url value="/logout" />" method="post" class="inline">
<div class="span-4 label">
<c:if test="${pageContext.request.userPrincipal != null}">
Welcome, ${pageContext.request.userPrincipal.name}
</c:if>
</div>
<div class="last">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<button id="submit" type="submit">Logout</button>
</div>
</form>
</security:authorize>
<security:authorize access="hasRole('ROLE_ANONYMOUS')">
<a href="<c:url value="/login" />">Login</a>
</security:authorize>
</div>
<div id="logo">
<p>
<a href="<c:url value="/" />">
<img src="<c:url value="/resources/images/header.jpg"/>" alt="Spring Travel" />
</a>
</p>
</div>
</div>
<div id="content">
<div id="local" class="span-6">
<p>
<a href="https://www.thespringexperience.com">
<img src="<c:url value="/resources/images/diplomat.jpg"/>" alt="generic hotel" />
</a>
</p>
<p>
<a href="https://www.thespringexperience.com">
<img src="<c:url value="/resources/images/springone2gx.jpeg"/>" alt="SpringOne 2GX" />
</a>
</p>
</div>
<div id="main" class="span-18 last">
<tiles:insertAttribute name="body" />
</div>
</div>
<hr />
<div id="footer">
<a href="https://www.springframework.org">
<img src="<c:url value="/resources/images/powered-by-spring.png"/>" alt="Powered by Spring" />
</a>
</div>
</div>
</body>
</html>

View File

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

View File

@@ -0,0 +1,120 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<div class="span-5">
<p>Valid username/passwords are:</p>
<ul>
<li>keith/melbourne</li>
<li>erwin/leuven</li>
<li>jeremy/atlanta</li>
<li>scott/rochester</li>
</ul>
</div>
<div class="span-10 append-2 last" xmlns:th="http://www.thymeleaf.org">
<div class="error" th:if="${param.login_error}">
Your login attempt was not successful, try again.<br /><br />
</div>
<form name="f" action="#" th:action="@{/loginProcess}" method="post">
<fieldset>
<legend>Login Information</legend>
<p>
<label for="username">User:</label>
<br />
<input type="text" name="username" id="username" />
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "username",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true }}));
// ]]>
</script>
<p>
<label for="password">Password:</label>
<br />
<input type="password" name="password" id="password" />
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "password",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true}}));
// ]]>
</script>
<p>
<input type="checkbox" name="_spring_security_remember_me" id="remember_me" />
<label for="remember_me">Don't ask for my password for two weeks:</label>
</p>
<script type="text/javascript">
// <![CDATA[
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "remember_me",
widgetType : "dijit.form.CheckBox"}));
// ]]>
</script>
<p>
<button id="submit" type="submit">Login</button>
<script type="text/javascript">
Spring.addDecoration(
new Spring.ValidateAllDecoration({event : 'onclick', elementId : 'submit'}));
</script>
</p>
</fieldset>
</form>
</div>
</div>
</body>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- END of the content to be included in the execution result -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</html>

View File

@@ -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" %>
<div class="span-5">
<p>Valid username/passwords are:</p>
<ul>
<li>keith/melbourne</li>
<li>erwin/leuven</li>
<li>jeremy/atlanta</li>
<li>scott/rochester</li>
</ul>
</div>
<div class="span-10 append-2 last">
<c:if test="${not empty param.login_error}">
<div class="error">
Your login attempt was not successful, try again.
</div>
</c:if>
<form name="f" action="<c:url value="/loginProcess" />" method="post">
<fieldset>
<legend>Login Information</legend>
<p>
<label for="username">User:</label>
<br />
<input type="text" name="username" id="username" />
</p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "username",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true }}));
</script>
<p>
<label for="password">Password:</label>
<br />
<input type="password" name="password" id="password" />
</p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "password",
widgetType : "dijit.form.ValidationTextBox",
widgetAttrs : { required : true}}));
</script>
<p>
<input type="checkbox" name="_spring_security_remember_me" id="remember_me" />
<label for="remember_me">Don't ask for my password for two weeks:</label>
</p>
<script type="text/javascript">
Spring.addDecoration(new Spring.ElementDecoration({
elementId : "remember_me",
widgetType : "dijit.form.CheckBox"}));
</script>
<div>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</div>
<p>
<button id="submit" type="submit">Login</button>
<script type="text/javascript">
Spring.addDecoration(new Spring.ValidateAllDecoration({event : 'onclick', elementId : 'submit'}));
</script>
</p>
</fieldset>
</form>
</div>

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org"
lang="en">
<head th:replace="layouts/standard.html :: //head">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- This <head> section is only used for static prototyping purposes. -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<title>Spring Travel: Spring MVC and Web Flow Reference Application</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/screen.css" />
<link rel="stylesheet" type="text/css" media="print"
href="../styles/blueprint/print.css" />
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="../styles/blueprint/ie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" media="screen" href="../styles/booking.css" />
</head>
<body th:replace="layouts/standard.html :: body(~{::bodyContent})">
<div th:fragment="bodyContent">
<h1>Logout</h1>
<p>You have successfully logged out.</p>
<hr />
<p><a href="hotels/searchForm.html" th:href="@{/hotels/search}">Continue</a></p>
</div>
</body>
</html>

View File

@@ -1,8 +0,0 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div>
<h1>Logout</h1>
<p>You have successfully logged out.</p>
<hr />
<p><a href="<c:url value="hotels/search" />">Continue</a></p>
</div>

View File

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

21
pom.xml
View File

@@ -10,26 +10,29 @@
<modules>
<module>booking-mvc</module>
<!--
<module>booking-faces</module>
<module>primefaces-showcase</module>
<module>webflow-showcase</module>
-->
</modules>
<properties>
<easymock.version>3.4</easymock.version>
<hsqldb.version>2.5.1</hsqldb.version>
<hibernate.version>5.4.33.Final</hibernate.version>
<hibernate-validator.version>6.2.3.Final</hibernate-validator.version>
<hibernate.version>5.6.10.Final</hibernate.version>
<hibernate-validator.version>7.0.4.Final</hibernate-validator.version>
<jaxb.version>2.2.3</jaxb.version>
<jetty-maven-plugin.version>9.4.48.v20220622</jetty-maven-plugin.version>
<jetty-maven-plugin.version>11.0.11</jetty-maven-plugin.version>
<jsp-api.version>3.0.0</jsp-api.version>
<jstl-api>2.0.0</jstl-api>
<junit.version>4.13.2</junit.version>
<log4j.version>2.14.0</log4j.version>
<mojarra.version>2.2.20</mojarra.version>
<myfaces.version>2.3.8</myfaces.version>
<primefaces.version>8.0</primefaces.version>
<servlet.version>3.1.0</servlet.version>
<tiles.version>3.0.8</tiles.version>
<webflow.version>2.5.1.RELEASE</webflow.version>
<servlet.version>5.0.0</servlet.version>
<webflow.version>3.0.0-SNAPSHOT</webflow.version>
</properties>
<dependencyManagement>
@@ -37,7 +40,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.22</version>
<version>6.0.0-M5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -46,7 +49,7 @@
<artifactId>spring-security-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>5.6.6</version>
<version>6.0.0-M5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -56,7 +59,6 @@
</dependencies>
</dependencyManagement>
<!--
<repositories>
<repository>
<id>spring-snapshot</id>
@@ -69,6 +71,5 @@
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
-->
</project>