mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Upgrade to Thymeleaf 3 and drop support for Thymleaf 2
This commit raises the minimum supported version of Thymeleaf to 3.0.x. It also upgrades Spring Social to a version that is compatible with Thymeleaf 3. Closes gh-7450 Closes gh-6258 See gh-7885
This commit is contained in:
parent
9c77708fcb
commit
9bba73a1a9
@ -526,6 +526,11 @@
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web-thymeleaf3</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-facebook</artifactId>
|
||||
@ -553,7 +558,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<artifactId>thymeleaf-spring5</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -571,11 +576,6 @@
|
||||
<artifactId>thymeleaf-extras-data-attribute</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-conditionalcomments</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-java8time</artifactId>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.mobile;
|
||||
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -18,7 +18,7 @@ package org.springframework.boot.autoconfigure.social;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
|
||||
import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
|
||||
import org.springframework.boot.autoconfigure.template.TemplateLocation;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* Abstract base class for the configuration of a Thymeleaf {@link TemplateResolver}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
abstract class AbstractTemplateResolverConfiguration {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(AbstractTemplateResolverConfiguration.class);
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
AbstractTemplateResolverConfiguration(ThymeleafProperties properties,
|
||||
ApplicationContext applicationContext) {
|
||||
this.properties = properties;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
protected final ThymeleafProperties getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void checkTemplateLocationExists() {
|
||||
boolean checkTemplateLocation = this.properties.isCheckTemplateLocation();
|
||||
if (checkTemplateLocation) {
|
||||
TemplateLocation location = new TemplateLocation(this.properties.getPrefix());
|
||||
if (!location.exists(this.applicationContext)) {
|
||||
logger.warn("Cannot find template location: " + location
|
||||
+ " (please add some templates or check "
|
||||
+ "your Thymeleaf configuration)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringResourceTemplateResolver defaultTemplateResolver() {
|
||||
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
||||
resolver.setApplicationContext(this.applicationContext);
|
||||
resolver.setPrefix(this.properties.getPrefix());
|
||||
resolver.setSuffix(this.properties.getSuffix());
|
||||
resolver.setTemplateMode(this.properties.getMode());
|
||||
if (this.properties.getEncoding() != null) {
|
||||
resolver.setCharacterEncoding(this.properties.getEncoding().name());
|
||||
}
|
||||
resolver.setCacheable(this.properties.isCache());
|
||||
Integer order = this.properties.getTemplateResolverOrder();
|
||||
if (order != null) {
|
||||
resolver.setOrder(order);
|
||||
}
|
||||
return resolver;
|
||||
}
|
||||
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* Abstract base class for the configuration of a {@link ThymeleafViewResolver}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
abstract class AbstractThymeleafViewResolverConfiguration {
|
||||
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
private final SpringTemplateEngine templateEngine;
|
||||
|
||||
protected AbstractThymeleafViewResolverConfiguration(ThymeleafProperties properties,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
this.properties = properties;
|
||||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
|
||||
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
|
||||
public ThymeleafViewResolver thymeleafViewResolver() {
|
||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||
configureTemplateEngine(resolver, this.templateEngine);
|
||||
resolver.setCharacterEncoding(this.properties.getEncoding().name());
|
||||
resolver.setContentType(appendCharset(this.properties.getContentType(),
|
||||
resolver.getCharacterEncoding()));
|
||||
resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
|
||||
resolver.setViewNames(this.properties.getViewNames());
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
resolver.setCache(this.properties.isCache());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
protected abstract void configureTemplateEngine(ThymeleafViewResolver resolver,
|
||||
SpringTemplateEngine templateEngine);
|
||||
|
||||
private String appendCharset(MimeType type, String charset) {
|
||||
if (type.getCharset() != null) {
|
||||
return type.toString();
|
||||
}
|
||||
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
|
||||
parameters.put("charset", charset);
|
||||
parameters.putAll(type.getParameters());
|
||||
return new MimeType(type, parameters).toString();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,21 +16,23 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.thymeleaf;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import com.github.mxab.thymeleaf.extras.dataattribute.dialect.DataAttributeDialect;
|
||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.thymeleaf.dialect.IDialect;
|
||||
import org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect;
|
||||
import org.thymeleaf.extras.java8time.dialect.Java8TimeDialect;
|
||||
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring4.resourceresolver.SpringResourceResourceResolver;
|
||||
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
|
||||
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.templatemode.TemplateMode;
|
||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
@ -38,16 +40,18 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.template.TemplateLocation;
|
||||
import org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain;
|
||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||
|
||||
/**
|
||||
@ -61,118 +65,103 @@ import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(ThymeleafProperties.class)
|
||||
@ConditionalOnClass(SpringTemplateEngine.class)
|
||||
@ConditionalOnClass(TemplateMode.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class ThymeleafAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingClass("org.thymeleaf.templatemode.TemplateMode")
|
||||
static class Thymeleaf2Configuration {
|
||||
@ConditionalOnMissingBean(name = "defaultTemplateResolver")
|
||||
static class DefaultTemplateResolverConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(name = "defaultTemplateResolver")
|
||||
static class DefaultTemplateResolverConfiguration
|
||||
extends AbstractTemplateResolverConfiguration {
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(DefaultTemplateResolverConfiguration.class);
|
||||
|
||||
DefaultTemplateResolverConfiguration(ThymeleafProperties properties,
|
||||
ApplicationContext applicationContext) {
|
||||
super(properties, applicationContext);
|
||||
}
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
@Bean
|
||||
public SpringResourceResourceResolver thymeleafResourceResolver() {
|
||||
return new SpringResourceResourceResolver();
|
||||
}
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
DefaultTemplateResolverConfiguration(ThymeleafProperties properties,
|
||||
ApplicationContext applicationContext) {
|
||||
this.properties = properties;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Servlet.class })
|
||||
@ConditionalOnWebApplication
|
||||
static class Thymeleaf2ViewResolverConfiguration
|
||||
extends AbstractThymeleafViewResolverConfiguration {
|
||||
|
||||
Thymeleaf2ViewResolverConfiguration(ThymeleafProperties properties,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
super(properties, templateEngine);
|
||||
@PostConstruct
|
||||
public void checkTemplateLocationExists() {
|
||||
boolean checkTemplateLocation = this.properties.isCheckTemplateLocation();
|
||||
if (checkTemplateLocation) {
|
||||
TemplateLocation location = new TemplateLocation(
|
||||
this.properties.getPrefix());
|
||||
if (!location.exists(this.applicationContext)) {
|
||||
logger.warn("Cannot find template location: " + location
|
||||
+ " (please add some templates or check "
|
||||
+ "your Thymeleaf configuration)");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureTemplateEngine(ThymeleafViewResolver resolver,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
resolver.setTemplateEngine(templateEngine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(ConditionalCommentsDialect.class)
|
||||
static class ThymeleafConditionalCommentsDialectConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ConditionalCommentsDialect conditionalCommentsDialect() {
|
||||
return new ConditionalCommentsDialect();
|
||||
@Bean
|
||||
public SpringResourceTemplateResolver defaultTemplateResolver() {
|
||||
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
|
||||
resolver.setApplicationContext(this.applicationContext);
|
||||
resolver.setPrefix(this.properties.getPrefix());
|
||||
resolver.setSuffix(this.properties.getSuffix());
|
||||
resolver.setTemplateMode(this.properties.getMode());
|
||||
if (this.properties.getEncoding() != null) {
|
||||
resolver.setCharacterEncoding(this.properties.getEncoding().name());
|
||||
}
|
||||
|
||||
resolver.setCacheable(this.properties.isCache());
|
||||
Integer order = this.properties.getTemplateResolverOrder();
|
||||
if (order != null) {
|
||||
resolver.setOrder(order);
|
||||
}
|
||||
resolver.setCheckExistence(this.properties.isCheckTemplate());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(name = "org.thymeleaf.templatemode.TemplateMode")
|
||||
static class Thymeleaf3Configuration {
|
||||
@ConditionalOnClass({ Servlet.class })
|
||||
@ConditionalOnWebApplication
|
||||
static class ThymeleafViewResolverConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean(name = "defaultTemplateResolver")
|
||||
static class DefaultTemplateResolverConfiguration
|
||||
extends AbstractTemplateResolverConfiguration {
|
||||
private final ThymeleafProperties properties;
|
||||
|
||||
DefaultTemplateResolverConfiguration(ThymeleafProperties properties,
|
||||
ApplicationContext applicationContext) {
|
||||
super(properties, applicationContext);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public SpringResourceTemplateResolver defaultTemplateResolver() {
|
||||
SpringResourceTemplateResolver resolver = super.defaultTemplateResolver();
|
||||
Method setCheckExistence = ReflectionUtils.findMethod(resolver.getClass(),
|
||||
"setCheckExistence", boolean.class);
|
||||
ReflectionUtils.invokeMethod(setCheckExistence, resolver,
|
||||
getProperties().isCheckTemplate());
|
||||
return resolver;
|
||||
}
|
||||
private final SpringTemplateEngine templateEngine;
|
||||
|
||||
ThymeleafViewResolverConfiguration(ThymeleafProperties properties,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
this.properties = properties;
|
||||
this.templateEngine = templateEngine;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Servlet.class })
|
||||
@ConditionalOnWebApplication
|
||||
static class Thymeleaf3ViewResolverConfiguration
|
||||
extends AbstractThymeleafViewResolverConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "thymeleafViewResolver")
|
||||
@ConditionalOnProperty(name = "spring.thymeleaf.enabled", matchIfMissing = true)
|
||||
public ThymeleafViewResolver thymeleafViewResolver() {
|
||||
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
|
||||
resolver.setTemplateEngine(this.templateEngine);
|
||||
resolver.setCharacterEncoding(this.properties.getEncoding().name());
|
||||
resolver.setContentType(appendCharset(this.properties.getContentType(),
|
||||
resolver.getCharacterEncoding()));
|
||||
resolver.setExcludedViewNames(this.properties.getExcludedViewNames());
|
||||
resolver.setViewNames(this.properties.getViewNames());
|
||||
// This resolver acts as a fallback resolver (e.g. like a
|
||||
// InternalResourceViewResolver) so it needs to have low precedence
|
||||
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 5);
|
||||
resolver.setCache(this.properties.isCache());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
Thymeleaf3ViewResolverConfiguration(ThymeleafProperties properties,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
super(properties, templateEngine);
|
||||
private String appendCharset(MimeType type, String charset) {
|
||||
if (type.getCharset() != null) {
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureTemplateEngine(ThymeleafViewResolver resolver,
|
||||
SpringTemplateEngine templateEngine) {
|
||||
Method setTemplateEngine;
|
||||
try {
|
||||
setTemplateEngine = ReflectionUtils.findMethod(resolver.getClass(),
|
||||
"setTemplateEngine",
|
||||
Class.forName("org.thymeleaf.ITemplateEngine", true,
|
||||
resolver.getClass().getClassLoader()));
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
ReflectionUtils.invokeMethod(setTemplateEngine, resolver, templateEngine);
|
||||
}
|
||||
|
||||
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
|
||||
parameters.put("charset", charset);
|
||||
parameters.putAll(type.getParameters());
|
||||
return new MimeType(type, parameters).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class ThymeleafProperties {
|
||||
public static final String DEFAULT_SUFFIX = ".html";
|
||||
|
||||
/**
|
||||
* Check that the template exists before rendering it (Thymeleaf 3+).
|
||||
* Check that the template exists before rendering it.
|
||||
*/
|
||||
private boolean checkTemplate = true;
|
||||
|
||||
@ -59,9 +59,10 @@ public class ThymeleafProperties {
|
||||
private String suffix = DEFAULT_SUFFIX;
|
||||
|
||||
/**
|
||||
* Template mode to be applied to templates. See also StandardTemplateModeHandlers.
|
||||
* Template mode to be applied to templates. See also
|
||||
* org.thymeleaf.templatemode.TemplateMode.
|
||||
*/
|
||||
private String mode = "HTML5";
|
||||
private String mode = "HTML";
|
||||
|
||||
/**
|
||||
* Template encoding.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -36,7 +36,7 @@ public class ThymeleafTemplateAvailabilityProvider
|
||||
@Override
|
||||
public boolean isTemplateAvailable(String view, Environment environment,
|
||||
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
||||
if (ClassUtils.isPresent("org.thymeleaf.spring4.SpringTemplateEngine",
|
||||
if (ClassUtils.isPresent("org.thymeleaf.spring5.SpringTemplateEngine",
|
||||
classLoader)) {
|
||||
PropertyResolver resolver = new RelaxedPropertyResolver(environment,
|
||||
"spring.thymeleaf.");
|
||||
|
@ -24,7 +24,7 @@ import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.PropertyAccessor;
|
||||
|
@ -27,10 +27,10 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.context.Context;
|
||||
import org.thymeleaf.spring4.view.ThymeleafView;
|
||||
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
|
||||
import org.thymeleaf.spring5.view.ThymeleafView;
|
||||
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
|
||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
@ -92,10 +92,9 @@ public class ThymeleafAutoConfigurationTests {
|
||||
this.context.register(ThymeleafAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
this.context.getBean(TemplateEngine.class).initialize();
|
||||
ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
|
||||
assertThat(resolver instanceof TemplateResolver).isTrue();
|
||||
assertThat(((TemplateResolver) resolver).getCharacterEncoding())
|
||||
assertThat(resolver instanceof SpringResourceTemplateResolver).isTrue();
|
||||
assertThat(((SpringResourceTemplateResolver) resolver).getCharacterEncoding())
|
||||
.isEqualTo("UTF-16");
|
||||
ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
|
||||
assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
|
||||
@ -109,7 +108,6 @@ public class ThymeleafAutoConfigurationTests {
|
||||
this.context.register(ThymeleafAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
this.context.getBean(TemplateEngine.class).initialize();
|
||||
ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
|
||||
assertThat(resolver.getOrder()).isEqualTo(Integer.valueOf(25));
|
||||
}
|
||||
@ -252,8 +250,8 @@ public class ThymeleafAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.cache:false");
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(ThymeleafViewResolver.class).isCache()).isFalse();
|
||||
TemplateResolver templateResolver = this.context.getBean(TemplateResolver.class);
|
||||
templateResolver.initialize();
|
||||
SpringResourceTemplateResolver templateResolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
assertThat(templateResolver.isCacheable()).isFalse();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package app
|
||||
|
||||
@Grab("thymeleaf-spring4")
|
||||
@Grab("thymeleaf-spring5")
|
||||
@Controller
|
||||
class Example {
|
||||
|
||||
|
@ -167,7 +167,7 @@
|
||||
<spring-security-jwt.version>1.0.7.RELEASE</spring-security-jwt.version>
|
||||
<spring-security-oauth.version>2.0.12.RELEASE</spring-security-oauth.version>
|
||||
<spring-session.version>2.0.0.BUILD-SNAPSHOT</spring-session.version>
|
||||
<spring-social.version>2.0.0.M1</spring-social.version>
|
||||
<spring-social.version>2.0.0.M2</spring-social.version>
|
||||
<spring-social-facebook.version>3.0.0.M1</spring-social-facebook.version>
|
||||
<spring-social-linkedin.version>2.0.0.M1</spring-social-linkedin.version>
|
||||
<spring-social-twitter.version>2.0.0.M1</spring-social-twitter.version>
|
||||
@ -175,12 +175,12 @@
|
||||
<sqlite-jdbc.version>3.15.1</sqlite-jdbc.version>
|
||||
<statsd-client.version>3.1.0</statsd-client.version>
|
||||
<sun-mail.version>${javax-mail.version}</sun-mail.version>
|
||||
<thymeleaf.version>2.1.5.RELEASE</thymeleaf.version>
|
||||
<thymeleaf-extras-springsecurity4.version>2.1.3.RELEASE</thymeleaf-extras-springsecurity4.version>
|
||||
<thymeleaf-extras-conditionalcomments.version>2.1.2.RELEASE</thymeleaf-extras-conditionalcomments.version>
|
||||
<thymeleaf-layout-dialect.version>1.4.0</thymeleaf-layout-dialect.version>
|
||||
<thymeleaf-extras-data-attribute.version>1.3</thymeleaf-extras-data-attribute.version>
|
||||
<thymeleaf-extras-java8time.version>2.1.0.RELEASE</thymeleaf-extras-java8time.version>
|
||||
<thymeleaf.version>3.0.3.RELEASE</thymeleaf.version>
|
||||
<thymeleaf-spring5.version>3.0.3.M1</thymeleaf-spring5.version>
|
||||
<thymeleaf-extras-springsecurity4.version>3.0.1.RELEASE</thymeleaf-extras-springsecurity4.version>
|
||||
<thymeleaf-layout-dialect.version>2.1.2</thymeleaf-layout-dialect.version>
|
||||
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
|
||||
<thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf-extras-java8time.version>
|
||||
<tomcat.version>8.5.11</tomcat.version>
|
||||
<undertow.version>1.4.8.Final</undertow.version>
|
||||
<unboundid-ldapsdk.version>3.2.0</unboundid-ldapsdk.version>
|
||||
@ -2180,6 +2180,17 @@
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
<version>${spring-social.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web-thymeleaf3</artifactId>
|
||||
<version>${spring-social.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-facebook</artifactId>
|
||||
@ -2256,13 +2267,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<version>${thymeleaf.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-conditionalcomments</artifactId>
|
||||
<version>${thymeleaf-extras-conditionalcomments.version}</version>
|
||||
<artifactId>thymeleaf-spring5</artifactId>
|
||||
<version>${thymeleaf-spring5.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
|
@ -159,7 +159,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<artifactId>thymeleaf-spring5</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -28,7 +28,7 @@ import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.thymeleaf.templateresolver.TemplateResolver;
|
||||
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -93,16 +93,16 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
@Test
|
||||
public void thymeleafCacheIsFalse() throws Exception {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
|
||||
resolver.initialize();
|
||||
SpringResourceTemplateResolver resolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
assertThat(resolver.isCacheable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPropertyCanBeOverriddenFromCommandLine() throws Exception {
|
||||
this.context = initializeAndRun(Config.class, "--spring.thymeleaf.cache=true");
|
||||
TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
|
||||
resolver.initialize();
|
||||
SpringResourceTemplateResolver resolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
assertThat(resolver.isCacheable()).isTrue();
|
||||
}
|
||||
|
||||
@ -113,8 +113,8 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||
new File("src/test/resources/user-home").getAbsolutePath());
|
||||
try {
|
||||
this.context = initializeAndRun(Config.class);
|
||||
TemplateResolver resolver = this.context.getBean(TemplateResolver.class);
|
||||
resolver.initialize();
|
||||
SpringResourceTemplateResolver resolver = this.context
|
||||
.getBean(SpringResourceTemplateResolver.class);
|
||||
assertThat(resolver.isCacheable()).isTrue();
|
||||
}
|
||||
finally {
|
||||
|
@ -700,12 +700,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-conditionalcomments</artifactId>
|
||||
<artifactId>thymeleaf-spring5</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -424,7 +424,7 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.thymeleaf.enabled=true # Enable MVC Thymeleaf view resolution.
|
||||
spring.thymeleaf.encoding=UTF-8 # Template encoding.
|
||||
spring.thymeleaf.excluded-view-names= # Comma-separated list of view names that should be excluded from resolution.
|
||||
spring.thymeleaf.mode=HTML5 # Template mode to be applied to templates. See also StandardTemplateModeHandlers.
|
||||
spring.thymeleaf.mode=HTML # Template mode to be applied to templates. See also org.thymeleaf.templatemode.TemplateMode.
|
||||
spring.thymeleaf.prefix=classpath:/templates/ # Prefix that gets prepended to view names when building a URL.
|
||||
spring.thymeleaf.suffix=.html # Suffix that gets appended to view names when building a URL.
|
||||
spring.thymeleaf.template-resolver-order= # Order of the template resolver in the chain.
|
||||
|
@ -216,7 +216,7 @@ number empty:
|
||||
----
|
||||
dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("org.thymeleaf:thymeleaf-spring4")
|
||||
compile("org.thymeleaf:thymeleaf-spring5")
|
||||
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
|
||||
}
|
||||
----
|
||||
|
@ -1248,42 +1248,6 @@ Check out {sc-spring-boot-autoconfigure}/web/WebMvcAutoConfiguration.{sc-ext}[`W
|
||||
|
||||
|
||||
|
||||
[[howto-use-thymeleaf-3]]
|
||||
=== Use Thymeleaf 3
|
||||
By default, `spring-boot-starter-thymeleaf` uses Thymeleaf 2.1. If you are using the
|
||||
`spring-boot-starter-parent`, you can use Thymeleaf 3 by overriding the
|
||||
`thymeleaf.version` and `thymeleaf-layout-dialect.version` properties, for example:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
<properties>
|
||||
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
||||
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
|
||||
</properties>
|
||||
----
|
||||
|
||||
NOTE: if you are managing dependencies yourself, look at `spring-boot-dependencies` for
|
||||
the list of artifacts that are related to those two versions.
|
||||
|
||||
To avoid a warning message about the HTML 5 template mode being deprecated and the HTML
|
||||
template mode being used instead, you may also want to explicitly configure
|
||||
`spring.thymeleaf.mode` to be `HTML`, for example:
|
||||
|
||||
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
spring.thymeleaf.mode: HTML
|
||||
----
|
||||
|
||||
Please refer to the
|
||||
{github-code}/spring-boot-samples/spring-boot-sample-web-thymeleaf3[Thymeleaf 3 sample] to
|
||||
see this in action.
|
||||
|
||||
If you are using any of the other auto-configured Thymeleaf Extras (Spring Security,
|
||||
Data Attribute, or Java 8 Time) you should also override each of their versions to one
|
||||
that is compatible with Thymeleaf 3.0.
|
||||
|
||||
|
||||
|
||||
[[howto-http-clients]]
|
||||
== HTTP clients
|
||||
|
||||
|
@ -240,9 +240,6 @@ The following sample applications are provided:
|
||||
| link:spring-boot-sample-web-static[spring-boot-sample-web-static]
|
||||
| Web application that serves static files
|
||||
|
||||
| link:spring-boot-sample-web-thymeleaf3[spring-boot-sample-web-thymeleaf3]
|
||||
| Web application with a basic UI built using thymeleaf 3.x
|
||||
|
||||
| link:spring-boot-sample-web-ui[spring-boot-sample-web-ui]
|
||||
| Web application with a basic UI built using Bootstrap and JQuery
|
||||
|
||||
|
@ -100,7 +100,6 @@
|
||||
<module>spring-boot-sample-web-secure-github</module>
|
||||
<module>spring-boot-sample-web-secure-jdbc</module>
|
||||
<module>spring-boot-sample-web-static</module>
|
||||
<module>spring-boot-sample-web-thymeleaf3</module>
|
||||
<module>spring-boot-sample-web-ui</module>
|
||||
<module>spring-boot-sample-websocket-jetty</module>
|
||||
<module>spring-boot-sample-websocket-tomcat</module>
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-samples</artifactId>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-sample-web-thymeleaf3</artifactId>
|
||||
<name>Spring Boot Web Thymeleaf 3 Sample</name>
|
||||
<description>Spring Boot Web Thymeleaf 3 Sample</description>
|
||||
<url>http://projects.spring.io/spring-boot/</url>
|
||||
<organization>
|
||||
<name>Pivotal Software, Inc.</name>
|
||||
<url>http://www.spring.io</url>
|
||||
</organization>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
||||
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Compile -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class InMemoryMessageRepository implements MessageRepository {
|
||||
|
||||
private static AtomicLong counter = new AtomicLong();
|
||||
|
||||
private final ConcurrentMap<Long, Message> messages = new ConcurrentHashMap<Long, Message>();
|
||||
|
||||
@Override
|
||||
public Iterable<Message> findAll() {
|
||||
return this.messages.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message save(Message message) {
|
||||
Long id = message.getId();
|
||||
if (id == null) {
|
||||
id = counter.incrementAndGet();
|
||||
message.setId(id);
|
||||
}
|
||||
this.messages.put(id, message);
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message findMessage(Long id) {
|
||||
return this.messages.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMessage(Long id) {
|
||||
this.messages.remove(id);
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class Message {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NotEmpty(message = "Message is required.")
|
||||
private String text;
|
||||
|
||||
@NotEmpty(message = "Summary is required.")
|
||||
private String summary;
|
||||
|
||||
private Calendar created = Calendar.getInstance();
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Calendar getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
public void setCreated(Calendar created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return this.summary;
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public interface MessageRepository {
|
||||
|
||||
Iterable<Message> findAll();
|
||||
|
||||
Message save(Message message);
|
||||
|
||||
Message findMessage(Long id);
|
||||
|
||||
void deleteMessage(Long id);
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleWebThymeleaf3Application {
|
||||
|
||||
@Bean
|
||||
public MessageRepository messageRepository() {
|
||||
return new InMemoryMessageRepository();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Converter<String, Message> messageConverter() {
|
||||
return new Converter<String, Message>() {
|
||||
@Override
|
||||
public Message convert(String id) {
|
||||
return messageRepository().findMessage(Long.valueOf(id));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleWebThymeleaf3Application.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3.mvc;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import sample.web.thymeleaf3.Message;
|
||||
import sample.web.thymeleaf3.MessageRepository;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author Doo-Hwan Kwak
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class MessageController {
|
||||
|
||||
private final MessageRepository messageRepository;
|
||||
|
||||
public MessageController(MessageRepository messageRepository) {
|
||||
this.messageRepository = messageRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ModelAndView list() {
|
||||
Iterable<Message> messages = this.messageRepository.findAll();
|
||||
return new ModelAndView("messages/list", "messages", messages);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public ModelAndView view(@PathVariable("id") Message message) {
|
||||
return new ModelAndView("messages/view", "message", message);
|
||||
}
|
||||
|
||||
@GetMapping(params = "form")
|
||||
public String createForm(@ModelAttribute Message message) {
|
||||
return "messages/form";
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ModelAndView create(@Valid Message message, BindingResult result,
|
||||
RedirectAttributes redirect) {
|
||||
if (result.hasErrors()) {
|
||||
return new ModelAndView("messages/form", "formErrors", result.getAllErrors());
|
||||
}
|
||||
message = this.messageRepository.save(message);
|
||||
redirect.addFlashAttribute("globalMessage", "Successfully created a new message");
|
||||
return new ModelAndView("redirect:/{message.id}", "message.id", message.getId());
|
||||
}
|
||||
|
||||
@RequestMapping("foo")
|
||||
public String foo() {
|
||||
throw new RuntimeException("Expected exception in controller");
|
||||
}
|
||||
|
||||
@GetMapping(value = "delete/{id}")
|
||||
public ModelAndView delete(@PathVariable("id") Long id) {
|
||||
this.messageRepository.deleteMessage(id);
|
||||
Iterable<Message> messages = this.messageRepository.findAll();
|
||||
return new ModelAndView("messages/list", "messages", messages);
|
||||
}
|
||||
|
||||
@GetMapping(value = "modify/{id}")
|
||||
public ModelAndView modifyForm(@PathVariable("id") Message message) {
|
||||
return new ModelAndView("messages/form", "message", message);
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
# Allow Thymeleaf templates to be reloaded at dev time
|
||||
spring.thymeleaf.cache: false
|
||||
spring.thymeleaf.mode: html
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,1250 +0,0 @@
|
||||
/**
|
||||
* jQuery Validation Plugin @VERSION
|
||||
*
|
||||
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
||||
* http://docs.jquery.com/Plugins/Validation
|
||||
*
|
||||
* Copyright (c) 2012 Jörn Zaefferer
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.extend($.fn, {
|
||||
// http://docs.jquery.com/Plugins/Validation/validate
|
||||
validate: function( options ) {
|
||||
|
||||
// if nothing is selected, return nothing; can't chain anyway
|
||||
if (!this.length) {
|
||||
if (options && options.debug && window.console) {
|
||||
console.warn( "nothing selected, can't validate, returning nothing" );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// check if a validator for this form was already created
|
||||
var validator = $.data(this[0], 'validator');
|
||||
if ( validator ) {
|
||||
return validator;
|
||||
}
|
||||
|
||||
// Add novalidate tag if HTML5.
|
||||
this.attr('novalidate', 'novalidate');
|
||||
|
||||
validator = new $.validator( options, this[0] );
|
||||
$.data(this[0], 'validator', validator);
|
||||
|
||||
if ( validator.settings.onsubmit ) {
|
||||
|
||||
this.validateDelegate( ":submit", "click", function(ev) {
|
||||
if ( validator.settings.submitHandler ) {
|
||||
validator.submitButton = ev.target;
|
||||
}
|
||||
// allow suppressing validation by adding a cancel class to the submit button
|
||||
if ( $(ev.target).hasClass('cancel') ) {
|
||||
validator.cancelSubmit = true;
|
||||
}
|
||||
});
|
||||
|
||||
// validate the form on submit
|
||||
this.submit( function( event ) {
|
||||
if ( validator.settings.debug ) {
|
||||
// prevent form submit to be able to see console output
|
||||
event.preventDefault();
|
||||
}
|
||||
function handle() {
|
||||
var hidden;
|
||||
if ( validator.settings.submitHandler ) {
|
||||
if (validator.submitButton) {
|
||||
// insert a hidden input as a replacement for the missing submit button
|
||||
hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
|
||||
}
|
||||
validator.settings.submitHandler.call( validator, validator.currentForm, event );
|
||||
if (validator.submitButton) {
|
||||
// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
|
||||
hidden.remove();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// prevent submit for invalid forms or custom submit handlers
|
||||
if ( validator.cancelSubmit ) {
|
||||
validator.cancelSubmit = false;
|
||||
return handle();
|
||||
}
|
||||
if ( validator.form() ) {
|
||||
if ( validator.pendingRequest ) {
|
||||
validator.formSubmitted = true;
|
||||
return false;
|
||||
}
|
||||
return handle();
|
||||
} else {
|
||||
validator.focusInvalid();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return validator;
|
||||
},
|
||||
// http://docs.jquery.com/Plugins/Validation/valid
|
||||
valid: function() {
|
||||
if ( $(this[0]).is('form')) {
|
||||
return this.validate().form();
|
||||
} else {
|
||||
var valid = true;
|
||||
var validator = $(this[0].form).validate();
|
||||
this.each(function() {
|
||||
valid &= validator.element(this);
|
||||
});
|
||||
return valid;
|
||||
}
|
||||
},
|
||||
// attributes: space seperated list of attributes to retrieve and remove
|
||||
removeAttrs: function(attributes) {
|
||||
var result = {},
|
||||
$element = this;
|
||||
$.each(attributes.split(/\s/), function(index, value) {
|
||||
result[value] = $element.attr(value);
|
||||
$element.removeAttr(value);
|
||||
});
|
||||
return result;
|
||||
},
|
||||
// http://docs.jquery.com/Plugins/Validation/rules
|
||||
rules: function(command, argument) {
|
||||
var element = this[0];
|
||||
|
||||
if (command) {
|
||||
var settings = $.data(element.form, 'validator').settings;
|
||||
var staticRules = settings.rules;
|
||||
var existingRules = $.validator.staticRules(element);
|
||||
switch(command) {
|
||||
case "add":
|
||||
$.extend(existingRules, $.validator.normalizeRule(argument));
|
||||
staticRules[element.name] = existingRules;
|
||||
if (argument.messages) {
|
||||
settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (!argument) {
|
||||
delete staticRules[element.name];
|
||||
return existingRules;
|
||||
}
|
||||
var filtered = {};
|
||||
$.each(argument.split(/\s/), function(index, method) {
|
||||
filtered[method] = existingRules[method];
|
||||
delete existingRules[method];
|
||||
});
|
||||
return filtered;
|
||||
}
|
||||
}
|
||||
|
||||
var data = $.validator.normalizeRules(
|
||||
$.extend(
|
||||
{},
|
||||
$.validator.metadataRules(element),
|
||||
$.validator.classRules(element),
|
||||
$.validator.attributeRules(element),
|
||||
$.validator.staticRules(element)
|
||||
), element);
|
||||
|
||||
// make sure required is at front
|
||||
if (data.required) {
|
||||
var param = data.required;
|
||||
delete data.required;
|
||||
data = $.extend({required: param}, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
// Custom selectors
|
||||
$.extend($.expr[":"], {
|
||||
// http://docs.jquery.com/Plugins/Validation/blank
|
||||
blank: function(a) {return !$.trim("" + a.value);},
|
||||
// http://docs.jquery.com/Plugins/Validation/filled
|
||||
filled: function(a) {return !!$.trim("" + a.value);},
|
||||
// http://docs.jquery.com/Plugins/Validation/unchecked
|
||||
unchecked: function(a) {return !a.checked;}
|
||||
});
|
||||
|
||||
// constructor for validator
|
||||
$.validator = function( options, form ) {
|
||||
this.settings = $.extend( true, {}, $.validator.defaults, options );
|
||||
this.currentForm = form;
|
||||
this.init();
|
||||
};
|
||||
|
||||
$.validator.format = function(source, params) {
|
||||
if ( arguments.length === 1 ) {
|
||||
return function() {
|
||||
var args = $.makeArray(arguments);
|
||||
args.unshift(source);
|
||||
return $.validator.format.apply( this, args );
|
||||
};
|
||||
}
|
||||
if ( arguments.length > 2 && params.constructor !== Array ) {
|
||||
params = $.makeArray(arguments).slice(1);
|
||||
}
|
||||
if ( params.constructor !== Array ) {
|
||||
params = [ params ];
|
||||
}
|
||||
$.each(params, function(i, n) {
|
||||
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
|
||||
});
|
||||
return source;
|
||||
};
|
||||
|
||||
$.extend($.validator, {
|
||||
|
||||
defaults: {
|
||||
messages: {},
|
||||
groups: {},
|
||||
rules: {},
|
||||
errorClass: "error",
|
||||
validClass: "valid",
|
||||
errorElement: "label",
|
||||
focusInvalid: true,
|
||||
errorContainer: $( [] ),
|
||||
errorLabelContainer: $( [] ),
|
||||
onsubmit: true,
|
||||
ignore: ":hidden",
|
||||
ignoreTitle: false,
|
||||
onfocusin: function(element, event) {
|
||||
this.lastActive = element;
|
||||
|
||||
// hide error label and remove error class on focus if enabled
|
||||
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
|
||||
if ( this.settings.unhighlight ) {
|
||||
this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
|
||||
}
|
||||
this.addWrapper(this.errorsFor(element)).hide();
|
||||
}
|
||||
},
|
||||
onfocusout: function(element, event) {
|
||||
if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
|
||||
this.element(element);
|
||||
}
|
||||
},
|
||||
onkeyup: function(element, event) {
|
||||
if ( element.name in this.submitted || element === this.lastElement ) {
|
||||
this.element(element);
|
||||
}
|
||||
},
|
||||
onclick: function(element, event) {
|
||||
// click on selects, radiobuttons and checkboxes
|
||||
if ( element.name in this.submitted ) {
|
||||
this.element(element);
|
||||
}
|
||||
// or option elements, check parent select in that case
|
||||
else if (element.parentNode.name in this.submitted) {
|
||||
this.element(element.parentNode);
|
||||
}
|
||||
},
|
||||
highlight: function(element, errorClass, validClass) {
|
||||
if (element.type === 'radio') {
|
||||
this.findByName(element.name).addClass(errorClass).removeClass(validClass);
|
||||
} else {
|
||||
$(element).addClass(errorClass).removeClass(validClass);
|
||||
}
|
||||
},
|
||||
unhighlight: function(element, errorClass, validClass) {
|
||||
if (element.type === 'radio') {
|
||||
this.findByName(element.name).removeClass(errorClass).addClass(validClass);
|
||||
} else {
|
||||
$(element).removeClass(errorClass).addClass(validClass);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
|
||||
setDefaults: function(settings) {
|
||||
$.extend( $.validator.defaults, settings );
|
||||
},
|
||||
|
||||
messages: {
|
||||
required: "This field is required.",
|
||||
remote: "Please fix this field.",
|
||||
email: "Please enter a valid email address.",
|
||||
url: "Please enter a valid URL.",
|
||||
date: "Please enter a valid date.",
|
||||
dateISO: "Please enter a valid date (ISO).",
|
||||
number: "Please enter a valid number.",
|
||||
digits: "Please enter only digits.",
|
||||
creditcard: "Please enter a valid credit card number.",
|
||||
equalTo: "Please enter the same value again.",
|
||||
accept: "Please enter a value with a valid extension.",
|
||||
maxlength: $.validator.format("Please enter no more than {0} characters."),
|
||||
minlength: $.validator.format("Please enter at least {0} characters."),
|
||||
rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
|
||||
range: $.validator.format("Please enter a value between {0} and {1}."),
|
||||
max: $.validator.format("Please enter a value less than or equal to {0}."),
|
||||
min: $.validator.format("Please enter a value greater than or equal to {0}.")
|
||||
},
|
||||
|
||||
autoCreateRanges: false,
|
||||
|
||||
prototype: {
|
||||
|
||||
init: function() {
|
||||
this.labelContainer = $(this.settings.errorLabelContainer);
|
||||
this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
|
||||
this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
|
||||
this.submitted = {};
|
||||
this.valueCache = {};
|
||||
this.pendingRequest = 0;
|
||||
this.pending = {};
|
||||
this.invalid = {};
|
||||
this.reset();
|
||||
|
||||
var groups = (this.groups = {});
|
||||
$.each(this.settings.groups, function(key, value) {
|
||||
$.each(value.split(/\s/), function(index, name) {
|
||||
groups[name] = key;
|
||||
});
|
||||
});
|
||||
var rules = this.settings.rules;
|
||||
$.each(rules, function(key, value) {
|
||||
rules[key] = $.validator.normalizeRule(value);
|
||||
});
|
||||
|
||||
function delegate(event) {
|
||||
var validator = $.data(this[0].form, "validator"),
|
||||
eventType = "on" + event.type.replace(/^validate/, "");
|
||||
if (validator.settings[eventType]) {
|
||||
validator.settings[eventType].call(validator, this[0], event);
|
||||
}
|
||||
}
|
||||
$(this.currentForm)
|
||||
.validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, " +
|
||||
"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
|
||||
"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
|
||||
"[type='week'], [type='time'], [type='datetime-local'], " +
|
||||
"[type='range'], [type='color'] ",
|
||||
"focusin focusout keyup", delegate)
|
||||
.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
|
||||
|
||||
if (this.settings.invalidHandler) {
|
||||
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
|
||||
}
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/form
|
||||
form: function() {
|
||||
this.checkForm();
|
||||
$.extend(this.submitted, this.errorMap);
|
||||
this.invalid = $.extend({}, this.errorMap);
|
||||
if (!this.valid()) {
|
||||
$(this.currentForm).triggerHandler("invalid-form", [this]);
|
||||
}
|
||||
this.showErrors();
|
||||
return this.valid();
|
||||
},
|
||||
|
||||
checkForm: function() {
|
||||
this.prepareForm();
|
||||
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
|
||||
this.check( elements[i] );
|
||||
}
|
||||
return this.valid();
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/element
|
||||
element: function( element ) {
|
||||
element = this.validationTargetFor( this.clean( element ) );
|
||||
this.lastElement = element;
|
||||
this.prepareElement( element );
|
||||
this.currentElements = $(element);
|
||||
var result = this.check( element ) !== false;
|
||||
if (result) {
|
||||
delete this.invalid[element.name];
|
||||
} else {
|
||||
this.invalid[element.name] = true;
|
||||
}
|
||||
if ( !this.numberOfInvalids() ) {
|
||||
// Hide error containers on last error
|
||||
this.toHide = this.toHide.add( this.containers );
|
||||
}
|
||||
this.showErrors();
|
||||
return result;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
|
||||
showErrors: function(errors) {
|
||||
if(errors) {
|
||||
// add items to error list and map
|
||||
$.extend( this.errorMap, errors );
|
||||
this.errorList = [];
|
||||
for ( var name in errors ) {
|
||||
this.errorList.push({
|
||||
message: errors[name],
|
||||
element: this.findByName(name)[0]
|
||||
});
|
||||
}
|
||||
// remove items from success list
|
||||
this.successList = $.grep( this.successList, function(element) {
|
||||
return !(element.name in errors);
|
||||
});
|
||||
}
|
||||
if (this.settings.showErrors) {
|
||||
this.settings.showErrors.call( this, this.errorMap, this.errorList );
|
||||
} else {
|
||||
this.defaultShowErrors();
|
||||
}
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
|
||||
resetForm: function() {
|
||||
if ( $.fn.resetForm ) {
|
||||
$( this.currentForm ).resetForm();
|
||||
}
|
||||
this.submitted = {};
|
||||
this.lastElement = null;
|
||||
this.prepareForm();
|
||||
this.hideErrors();
|
||||
this.elements().removeClass( this.settings.errorClass );
|
||||
},
|
||||
|
||||
numberOfInvalids: function() {
|
||||
return this.objectLength(this.invalid);
|
||||
},
|
||||
|
||||
objectLength: function( obj ) {
|
||||
var count = 0;
|
||||
for ( var i in obj ) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
hideErrors: function() {
|
||||
this.addWrapper( this.toHide ).hide();
|
||||
},
|
||||
|
||||
valid: function() {
|
||||
return this.size() === 0;
|
||||
},
|
||||
|
||||
size: function() {
|
||||
return this.errorList.length;
|
||||
},
|
||||
|
||||
focusInvalid: function() {
|
||||
if( this.settings.focusInvalid ) {
|
||||
try {
|
||||
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
|
||||
.filter(":visible")
|
||||
.focus()
|
||||
// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
|
||||
.trigger("focusin");
|
||||
} catch(e) {
|
||||
// ignore IE throwing errors when focusing hidden elements
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
findLastActive: function() {
|
||||
var lastActive = this.lastActive;
|
||||
return lastActive && $.grep(this.errorList, function(n) {
|
||||
return n.element.name === lastActive.name;
|
||||
}).length === 1 && lastActive;
|
||||
},
|
||||
|
||||
elements: function() {
|
||||
var validator = this,
|
||||
rulesCache = {};
|
||||
|
||||
// select all valid inputs inside the form (no submit or reset buttons)
|
||||
return $(this.currentForm)
|
||||
.find("input, select, textarea")
|
||||
.not(":submit, :reset, :image, [disabled]")
|
||||
.not( this.settings.ignore )
|
||||
.filter(function() {
|
||||
if ( !this.name && validator.settings.debug && window.console ) {
|
||||
console.error( "%o has no name assigned", this);
|
||||
}
|
||||
|
||||
// select only the first element for each name, and only those with rules specified
|
||||
if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rulesCache[this.name] = true;
|
||||
return true;
|
||||
});
|
||||
},
|
||||
|
||||
clean: function( selector ) {
|
||||
return $( selector )[0];
|
||||
},
|
||||
|
||||
errors: function() {
|
||||
var errorClass = this.settings.errorClass.replace(' ', '.');
|
||||
return $( this.settings.errorElement + "." + errorClass, this.errorContext );
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.successList = [];
|
||||
this.errorList = [];
|
||||
this.errorMap = {};
|
||||
this.toShow = $([]);
|
||||
this.toHide = $([]);
|
||||
this.currentElements = $([]);
|
||||
},
|
||||
|
||||
prepareForm: function() {
|
||||
this.reset();
|
||||
this.toHide = this.errors().add( this.containers );
|
||||
},
|
||||
|
||||
prepareElement: function( element ) {
|
||||
this.reset();
|
||||
this.toHide = this.errorsFor(element);
|
||||
},
|
||||
|
||||
elementValue: function( element ) {
|
||||
var val = $(element).val();
|
||||
if( typeof val === 'string' ) {
|
||||
return val.replace(/\r/g, "");
|
||||
}
|
||||
return val;
|
||||
},
|
||||
|
||||
check: function( element ) {
|
||||
element = this.validationTargetFor( this.clean( element ) );
|
||||
|
||||
var rules = $(element).rules();
|
||||
var dependencyMismatch = false;
|
||||
var val = this.elementValue(element);
|
||||
var result;
|
||||
|
||||
for (var method in rules ) {
|
||||
var rule = { method: method, parameters: rules[method] };
|
||||
try {
|
||||
|
||||
result = $.validator.methods[method].call( this, val, element, rule.parameters );
|
||||
|
||||
// if a method indicates that the field is optional and therefore valid,
|
||||
// don't mark it as valid when there are no other rules
|
||||
if ( result === "dependency-mismatch" ) {
|
||||
dependencyMismatch = true;
|
||||
continue;
|
||||
}
|
||||
dependencyMismatch = false;
|
||||
|
||||
if ( result === "pending" ) {
|
||||
this.toHide = this.toHide.not( this.errorsFor(element) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !result ) {
|
||||
this.formatAndAdd( element, rule );
|
||||
return false;
|
||||
}
|
||||
} catch(e) {
|
||||
if ( this.settings.debug && window.console ) {
|
||||
console.log("exception occured when checking element " + element.id + ", check the '" + rule.method + "' method", e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (dependencyMismatch) {
|
||||
return;
|
||||
}
|
||||
if ( this.objectLength(rules) ) {
|
||||
this.successList.push(element);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// return the custom message for the given element and validation method
|
||||
// specified in the element's "messages" metadata
|
||||
customMetaMessage: function(element, method) {
|
||||
if (!$.metadata) {
|
||||
return;
|
||||
}
|
||||
var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata();
|
||||
return meta && meta.messages && meta.messages[method];
|
||||
},
|
||||
|
||||
// return the custom message for the given element name and validation method
|
||||
customMessage: function( name, method ) {
|
||||
var m = this.settings.messages[name];
|
||||
return m && (m.constructor === String ? m : m[method]);
|
||||
},
|
||||
|
||||
// return the first defined argument, allowing empty strings
|
||||
findDefined: function() {
|
||||
for(var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] !== undefined) {
|
||||
return arguments[i];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
defaultMessage: function( element, method) {
|
||||
return this.findDefined(
|
||||
this.customMessage( element.name, method ),
|
||||
this.customMetaMessage( element, method ),
|
||||
// title is never undefined, so handle empty string as undefined
|
||||
!this.settings.ignoreTitle && element.title || undefined,
|
||||
$.validator.messages[method],
|
||||
"<strong>Warning: No message defined for " + element.name + "</strong>"
|
||||
);
|
||||
},
|
||||
|
||||
formatAndAdd: function( element, rule ) {
|
||||
var message = this.defaultMessage( element, rule.method ),
|
||||
theregex = /\$?\{(\d+)\}/g;
|
||||
if ( typeof message === "function" ) {
|
||||
message = message.call(this, rule.parameters, element);
|
||||
} else if (theregex.test(message)) {
|
||||
message = $.validator.format(message.replace(theregex, '{$1}'), rule.parameters);
|
||||
}
|
||||
this.errorList.push({
|
||||
message: message,
|
||||
element: element
|
||||
});
|
||||
|
||||
this.errorMap[element.name] = message;
|
||||
this.submitted[element.name] = message;
|
||||
},
|
||||
|
||||
addWrapper: function(toToggle) {
|
||||
if ( this.settings.wrapper ) {
|
||||
toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
|
||||
}
|
||||
return toToggle;
|
||||
},
|
||||
|
||||
defaultShowErrors: function() {
|
||||
var i, elements;
|
||||
for ( i = 0; this.errorList[i]; i++ ) {
|
||||
var error = this.errorList[i];
|
||||
if ( this.settings.highlight ) {
|
||||
this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
|
||||
}
|
||||
this.showLabel( error.element, error.message );
|
||||
}
|
||||
if( this.errorList.length ) {
|
||||
this.toShow = this.toShow.add( this.containers );
|
||||
}
|
||||
if (this.settings.success) {
|
||||
for ( i = 0; this.successList[i]; i++ ) {
|
||||
this.showLabel( this.successList[i] );
|
||||
}
|
||||
}
|
||||
if (this.settings.unhighlight) {
|
||||
for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
|
||||
this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
|
||||
}
|
||||
}
|
||||
this.toHide = this.toHide.not( this.toShow );
|
||||
this.hideErrors();
|
||||
this.addWrapper( this.toShow ).show();
|
||||
},
|
||||
|
||||
validElements: function() {
|
||||
return this.currentElements.not(this.invalidElements());
|
||||
},
|
||||
|
||||
invalidElements: function() {
|
||||
return $(this.errorList).map(function() {
|
||||
return this.element;
|
||||
});
|
||||
},
|
||||
|
||||
showLabel: function(element, message) {
|
||||
var label = this.errorsFor( element );
|
||||
if ( label.length ) {
|
||||
// refresh error/success class
|
||||
label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
|
||||
|
||||
// check if we have a generated label, replace the message then
|
||||
if ( label.attr("generated") ) {
|
||||
label.html(message);
|
||||
}
|
||||
} else {
|
||||
// create label
|
||||
label = $("<" + this.settings.errorElement + "/>")
|
||||
.attr({"for": this.idOrName(element), generated: true})
|
||||
.addClass(this.settings.errorClass)
|
||||
.html(message || "");
|
||||
if ( this.settings.wrapper ) {
|
||||
// make sure the element is visible, even in IE
|
||||
// actually showing the wrapped element is handled elsewhere
|
||||
label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
|
||||
}
|
||||
if ( !this.labelContainer.append(label).length ) {
|
||||
if ( this.settings.errorPlacement ) {
|
||||
this.settings.errorPlacement(label, $(element) );
|
||||
} else {
|
||||
label.insertAfter(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !message && this.settings.success ) {
|
||||
label.text("");
|
||||
if ( typeof this.settings.success === "string" ) {
|
||||
label.addClass( this.settings.success );
|
||||
} else {
|
||||
this.settings.success( label );
|
||||
}
|
||||
}
|
||||
this.toShow = this.toShow.add(label);
|
||||
},
|
||||
|
||||
errorsFor: function(element) {
|
||||
var name = this.idOrName(element);
|
||||
return this.errors().filter(function() {
|
||||
return $(this).attr('for') === name;
|
||||
});
|
||||
},
|
||||
|
||||
idOrName: function(element) {
|
||||
return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
|
||||
},
|
||||
|
||||
validationTargetFor: function(element) {
|
||||
// if radio/checkbox, validate first element in group instead
|
||||
if (this.checkable(element)) {
|
||||
element = this.findByName( element.name ).not(this.settings.ignore)[0];
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
checkable: function( element ) {
|
||||
return (/radio|checkbox/i).test(element.type);
|
||||
},
|
||||
|
||||
findByName: function( name ) {
|
||||
// select by name and filter by form for performance over form.find("[name=...]")
|
||||
var form = this.currentForm;
|
||||
return $(document.getElementsByName(name)).map(function(index, element) {
|
||||
return element.form === form && element.name === name && element || null;
|
||||
});
|
||||
},
|
||||
|
||||
getLength: function(value, element) {
|
||||
switch( element.nodeName.toLowerCase() ) {
|
||||
case 'select':
|
||||
return $("option:selected", element).length;
|
||||
case 'input':
|
||||
if( this.checkable( element) ) {
|
||||
return this.findByName(element.name).filter(':checked').length;
|
||||
}
|
||||
}
|
||||
return value.length;
|
||||
},
|
||||
|
||||
depend: function(param, element) {
|
||||
return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
|
||||
},
|
||||
|
||||
dependTypes: {
|
||||
"boolean": function(param, element) {
|
||||
return param;
|
||||
},
|
||||
"string": function(param, element) {
|
||||
return !!$(param, element.form).length;
|
||||
},
|
||||
"function": function(param, element) {
|
||||
return param(element);
|
||||
}
|
||||
},
|
||||
|
||||
optional: function(element) {
|
||||
var val = this.elementValue(element);
|
||||
return !$.validator.methods.required.call(this, val, element) && "dependency-mismatch";
|
||||
},
|
||||
|
||||
startRequest: function(element) {
|
||||
if (!this.pending[element.name]) {
|
||||
this.pendingRequest++;
|
||||
this.pending[element.name] = true;
|
||||
}
|
||||
},
|
||||
|
||||
stopRequest: function(element, valid) {
|
||||
this.pendingRequest--;
|
||||
// sometimes synchronization fails, make sure pendingRequest is never < 0
|
||||
if (this.pendingRequest < 0) {
|
||||
this.pendingRequest = 0;
|
||||
}
|
||||
delete this.pending[element.name];
|
||||
if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
|
||||
$(this.currentForm).submit();
|
||||
this.formSubmitted = false;
|
||||
} else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {
|
||||
$(this.currentForm).triggerHandler("invalid-form", [this]);
|
||||
this.formSubmitted = false;
|
||||
}
|
||||
},
|
||||
|
||||
previousValue: function(element) {
|
||||
return $.data(element, "previousValue") || $.data(element, "previousValue", {
|
||||
old: null,
|
||||
valid: true,
|
||||
message: this.defaultMessage( element, "remote" )
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
classRuleSettings: {
|
||||
required: {required: true},
|
||||
email: {email: true},
|
||||
url: {url: true},
|
||||
date: {date: true},
|
||||
dateISO: {dateISO: true},
|
||||
number: {number: true},
|
||||
digits: {digits: true},
|
||||
creditcard: {creditcard: true}
|
||||
},
|
||||
|
||||
addClassRules: function(className, rules) {
|
||||
if ( className.constructor === String ) {
|
||||
this.classRuleSettings[className] = rules;
|
||||
} else {
|
||||
$.extend(this.classRuleSettings, className);
|
||||
}
|
||||
},
|
||||
|
||||
classRules: function(element) {
|
||||
var rules = {};
|
||||
var classes = $(element).attr('class');
|
||||
if ( classes ) {
|
||||
$.each(classes.split(' '), function() {
|
||||
if (this in $.validator.classRuleSettings) {
|
||||
$.extend(rules, $.validator.classRuleSettings[this]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return rules;
|
||||
},
|
||||
|
||||
attributeRules: function(element) {
|
||||
var rules = {};
|
||||
var $element = $(element);
|
||||
|
||||
for (var method in $.validator.methods) {
|
||||
var value;
|
||||
|
||||
// support for <input required> in both html5 and older browsers
|
||||
if (method === 'required') {
|
||||
value = $element.get(0).getAttribute(method);
|
||||
// Some browsers return an empty string for the required attribute
|
||||
// and non-HTML5 browsers might have required="" markup
|
||||
if (value === "") {
|
||||
value = true;
|
||||
} else if (value === "false") {
|
||||
value = false;
|
||||
}
|
||||
// force non-HTML5 browsers to return bool
|
||||
value = !!value;
|
||||
} else {
|
||||
value = $element.attr(method);
|
||||
}
|
||||
|
||||
if (value) {
|
||||
rules[method] = value;
|
||||
} else if ($element[0].getAttribute("type") === method) {
|
||||
rules[method] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
|
||||
if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
|
||||
delete rules.maxlength;
|
||||
}
|
||||
|
||||
return rules;
|
||||
},
|
||||
|
||||
metadataRules: function(element) {
|
||||
if (!$.metadata) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var meta = $.data(element.form, 'validator').settings.meta;
|
||||
return meta ?
|
||||
$(element).metadata()[meta] :
|
||||
$(element).metadata();
|
||||
},
|
||||
|
||||
staticRules: function(element) {
|
||||
var rules = {};
|
||||
var validator = $.data(element.form, 'validator');
|
||||
if (validator.settings.rules) {
|
||||
rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
|
||||
}
|
||||
return rules;
|
||||
},
|
||||
|
||||
normalizeRules: function(rules, element) {
|
||||
// handle dependency check
|
||||
$.each(rules, function(prop, val) {
|
||||
// ignore rule when param is explicitly false, eg. required:false
|
||||
if (val === false) {
|
||||
delete rules[prop];
|
||||
return;
|
||||
}
|
||||
if (val.param || val.depends) {
|
||||
var keepRule = true;
|
||||
switch (typeof val.depends) {
|
||||
case "string":
|
||||
keepRule = !!$(val.depends, element.form).length;
|
||||
break;
|
||||
case "function":
|
||||
keepRule = val.depends.call(element, element);
|
||||
break;
|
||||
}
|
||||
if (keepRule) {
|
||||
rules[prop] = val.param !== undefined ? val.param : true;
|
||||
} else {
|
||||
delete rules[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// evaluate parameters
|
||||
$.each(rules, function(rule, parameter) {
|
||||
rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
|
||||
});
|
||||
|
||||
// clean number parameters
|
||||
$.each(['minlength', 'maxlength', 'min', 'max'], function() {
|
||||
if (rules[this]) {
|
||||
rules[this] = Number(rules[this]);
|
||||
}
|
||||
});
|
||||
$.each(['rangelength', 'range'], function() {
|
||||
if (rules[this]) {
|
||||
rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
|
||||
}
|
||||
});
|
||||
|
||||
if ($.validator.autoCreateRanges) {
|
||||
// auto-create ranges
|
||||
if (rules.min && rules.max) {
|
||||
rules.range = [rules.min, rules.max];
|
||||
delete rules.min;
|
||||
delete rules.max;
|
||||
}
|
||||
if (rules.minlength && rules.maxlength) {
|
||||
rules.rangelength = [rules.minlength, rules.maxlength];
|
||||
delete rules.minlength;
|
||||
delete rules.maxlength;
|
||||
}
|
||||
}
|
||||
|
||||
// To support custom messages in metadata ignore rule methods titled "messages"
|
||||
if (rules.messages) {
|
||||
delete rules.messages;
|
||||
}
|
||||
|
||||
return rules;
|
||||
},
|
||||
|
||||
// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
|
||||
normalizeRule: function(data) {
|
||||
if( typeof data === "string" ) {
|
||||
var transformed = {};
|
||||
$.each(data.split(/\s/), function() {
|
||||
transformed[this] = true;
|
||||
});
|
||||
data = transformed;
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
|
||||
addMethod: function(name, method, message) {
|
||||
$.validator.methods[name] = method;
|
||||
$.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];
|
||||
if (method.length < 3) {
|
||||
$.validator.addClassRules(name, $.validator.normalizeRule(name));
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/required
|
||||
required: function(value, element, param) {
|
||||
// check if dependency is met
|
||||
if ( !this.depend(param, element) ) {
|
||||
return "dependency-mismatch";
|
||||
}
|
||||
if ( element.nodeName.toLowerCase() === "select" ) {
|
||||
// could be an array for select-multiple or a string, both are fine this way
|
||||
var val = $(element).val();
|
||||
return val && val.length > 0;
|
||||
}
|
||||
if ( this.checkable(element) ) {
|
||||
return this.getLength(value, element) > 0;
|
||||
}
|
||||
return $.trim(value).length > 0;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/remote
|
||||
remote: function(value, element, param) {
|
||||
if ( this.optional(element) ) {
|
||||
return "dependency-mismatch";
|
||||
}
|
||||
|
||||
var previous = this.previousValue(element);
|
||||
if (!this.settings.messages[element.name] ) {
|
||||
this.settings.messages[element.name] = {};
|
||||
}
|
||||
previous.originalMessage = this.settings.messages[element.name].remote;
|
||||
this.settings.messages[element.name].remote = previous.message;
|
||||
|
||||
param = typeof param === "string" && {url:param} || param;
|
||||
|
||||
if ( this.pending[element.name] ) {
|
||||
return "pending";
|
||||
}
|
||||
if ( previous.old === value ) {
|
||||
return previous.valid;
|
||||
}
|
||||
|
||||
previous.old = value;
|
||||
var validator = this;
|
||||
this.startRequest(element);
|
||||
var data = {};
|
||||
data[element.name] = value;
|
||||
$.ajax($.extend(true, {
|
||||
url: param,
|
||||
mode: "abort",
|
||||
port: "validate" + element.name,
|
||||
dataType: "json",
|
||||
data: data,
|
||||
success: function(response) {
|
||||
validator.settings.messages[element.name].remote = previous.originalMessage;
|
||||
var valid = response === true;
|
||||
if ( valid ) {
|
||||
var submitted = validator.formSubmitted;
|
||||
validator.prepareElement(element);
|
||||
validator.formSubmitted = submitted;
|
||||
validator.successList.push(element);
|
||||
validator.showErrors();
|
||||
} else {
|
||||
var errors = {};
|
||||
var message = response || validator.defaultMessage( element, "remote" );
|
||||
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
|
||||
validator.showErrors(errors);
|
||||
}
|
||||
previous.valid = valid;
|
||||
validator.stopRequest(element, valid);
|
||||
}
|
||||
}, param));
|
||||
return "pending";
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/minlength
|
||||
minlength: function(value, element, param) {
|
||||
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
||||
return this.optional(element) || length >= param;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
|
||||
maxlength: function(value, element, param) {
|
||||
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
||||
return this.optional(element) || length <= param;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
|
||||
rangelength: function(value, element, param) {
|
||||
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
||||
return this.optional(element) || ( length >= param[0] && length <= param[1] );
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/min
|
||||
min: function( value, element, param ) {
|
||||
return this.optional(element) || value >= param;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/max
|
||||
max: function( value, element, param ) {
|
||||
return this.optional(element) || value <= param;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/range
|
||||
range: function( value, element, param ) {
|
||||
return this.optional(element) || ( value >= param[0] && value <= param[1] );
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/email
|
||||
email: function(value, element) {
|
||||
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
|
||||
return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/url
|
||||
url: function(value, element) {
|
||||
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
|
||||
return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/date
|
||||
date: function(value, element) {
|
||||
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
|
||||
dateISO: function(value, element) {
|
||||
return this.optional(element) || /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value);
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/number
|
||||
number: function(value, element) {
|
||||
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/digits
|
||||
digits: function(value, element) {
|
||||
return this.optional(element) || /^\d+$/.test(value);
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
|
||||
// based on http://en.wikipedia.org/wiki/Luhn
|
||||
creditcard: function(value, element) {
|
||||
if ( this.optional(element) ) {
|
||||
return "dependency-mismatch";
|
||||
}
|
||||
// accept only spaces, digits and dashes
|
||||
if (/[^0-9 \-]+/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
var nCheck = 0,
|
||||
nDigit = 0,
|
||||
bEven = false;
|
||||
|
||||
value = value.replace(/\D/g, "");
|
||||
|
||||
for (var n = value.length - 1; n >= 0; n--) {
|
||||
var cDigit = value.charAt(n);
|
||||
nDigit = parseInt(cDigit, 10);
|
||||
if (bEven) {
|
||||
if ((nDigit *= 2) > 9) {
|
||||
nDigit -= 9;
|
||||
}
|
||||
}
|
||||
nCheck += nDigit;
|
||||
bEven = !bEven;
|
||||
}
|
||||
|
||||
return (nCheck % 10) === 0;
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/accept
|
||||
accept: function(value, element, param) {
|
||||
param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
|
||||
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
||||
},
|
||||
|
||||
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
|
||||
equalTo: function(value, element, param) {
|
||||
// bind to the blur event of the target in order to revalidate whenever the target field is updated
|
||||
// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
|
||||
var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
|
||||
$(element).valid();
|
||||
});
|
||||
return value === target.val();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// deprecated, use $.validator.format instead
|
||||
$.format = $.validator.format;
|
||||
|
||||
}(jQuery));
|
||||
|
||||
// ajax mode: abort
|
||||
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
|
||||
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
|
||||
(function($) {
|
||||
var pendingRequests = {};
|
||||
// Use a prefilter if available (1.5+)
|
||||
if ( $.ajaxPrefilter ) {
|
||||
$.ajaxPrefilter(function(settings, _, xhr) {
|
||||
var port = settings.port;
|
||||
if (settings.mode === "abort") {
|
||||
if ( pendingRequests[port] ) {
|
||||
pendingRequests[port].abort();
|
||||
}
|
||||
pendingRequests[port] = xhr;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Proxy ajax
|
||||
var ajax = $.ajax;
|
||||
$.ajax = function(settings) {
|
||||
var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
|
||||
port = ( "port" in settings ? settings : $.ajaxSettings ).port;
|
||||
if (mode === "abort") {
|
||||
if ( pendingRequests[port] ) {
|
||||
pendingRequests[port].abort();
|
||||
}
|
||||
return (pendingRequests[port] = ajax.apply(this, arguments));
|
||||
}
|
||||
return ajax.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
}(jQuery));
|
||||
|
||||
// provides cross-browser focusin and focusout events
|
||||
// IE has native support, in other browsers, use event caputuring (neither bubbles)
|
||||
|
||||
// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
|
||||
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
|
||||
(function($) {
|
||||
// only implement if not provided by jQuery core (since 1.4)
|
||||
// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
|
||||
if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
|
||||
$.each({
|
||||
focus: 'focusin',
|
||||
blur: 'focusout'
|
||||
}, function( original, fix ){
|
||||
$.event.special[fix] = {
|
||||
setup:function() {
|
||||
this.addEventListener( original, handler, true );
|
||||
},
|
||||
teardown:function() {
|
||||
this.removeEventListener( original, handler, true );
|
||||
},
|
||||
handler: function(e) {
|
||||
var args = arguments;
|
||||
args[0] = $.event.fix(e);
|
||||
args[0].type = fix;
|
||||
return $.event.handle.apply(this, args);
|
||||
}
|
||||
};
|
||||
function handler(e) {
|
||||
e = $.event.fix(e);
|
||||
e.type = fix;
|
||||
return $.event.handle.call(this, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.extend($.fn, {
|
||||
validateDelegate: function(delegate, type, handler) {
|
||||
return this.bind(type, function(event) {
|
||||
var target = $(event.target);
|
||||
if (target.is(delegate)) {
|
||||
return handler.apply(target, arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}(jQuery));
|
@ -1,25 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<title>Layout</title>
|
||||
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"
|
||||
href="../../css/bootstrap.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="navbar">
|
||||
<div class="navbar-inner">
|
||||
<a class="brand"
|
||||
href="https://github.com/ultraq/thymeleaf-layout-dialect">
|
||||
Thymeleaf - Layout </a>
|
||||
<ul class="nav">
|
||||
<li><a th:href="@{/}" href="messages.html"> Messages </a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<h1 layout:fragment="header">Layout</h1>
|
||||
<div layout:fragment="content">Fake content</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="layout">
|
||||
<head>
|
||||
<title>Messages : Create</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 layout:fragment="header">Messages : Create</h1>
|
||||
<div layout:fragment="content" class="container">
|
||||
<form id="messageForm" th:action="@{/(form)}" th:object="${message}"
|
||||
action="#" method="post">
|
||||
<div th:if="${#fields.hasErrors('*')}" class="alert alert-error">
|
||||
<p th:each="error : ${#fields.errors('*')}" th:text="${error}">
|
||||
Validation error</p>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a th:href="@{/}" href="messages.html"> Messages </a>
|
||||
</div>
|
||||
<input type="hidden" th:field="*{id}"
|
||||
th:class="${#fields.hasErrors('id')} ? 'field-error'" /> <label
|
||||
for="summary">Summary</label> <input type="text"
|
||||
th:field="*{summary}"
|
||||
th:class="${#fields.hasErrors('summary')} ? 'field-error'" /> <label
|
||||
for="text">Message</label>
|
||||
<textarea th:field="*{text}"
|
||||
th:class="${#fields.hasErrors('text')} ? 'field-error'"></textarea>
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="Save" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,37 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="layout">
|
||||
<head>
|
||||
<title>Messages : View all</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 layout:fragment="header">Messages : View all</h1>
|
||||
<div layout:fragment="content" class="container">
|
||||
<div class="pull-right">
|
||||
<a href="form.html" th:href="@{/(form)}">Create Message</a>
|
||||
</div>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>Created</td>
|
||||
<td>Summary</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:if="${messages.empty}">
|
||||
<td colspan="3">No messages</td>
|
||||
</tr>
|
||||
<tr th:each="message : ${messages}">
|
||||
<td th:text="${message.id}">1</td>
|
||||
<td th:text="${#calendars.format(message.created)}">July 11,
|
||||
2012 2:17:16 PM CDT</td>
|
||||
<td><a href="view.html" th:href="@{'/' + ${message.id}}"
|
||||
th:text="${message.summary}"> The summary </a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,35 +0,0 @@
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="layout">
|
||||
<head>
|
||||
<title>Messages : View</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1 layout:fragment="header">Messages : Create</h1>
|
||||
<div layout:fragment="content" class="container">
|
||||
<div class="alert alert-success" th:if="${globalMessage}"
|
||||
th:text="${globalMessage}">Some Success message</div>
|
||||
<div class="pull-right">
|
||||
<a th:href="@{/}" href="list.html"> Messages </a>
|
||||
</div>
|
||||
<dl>
|
||||
<dt>ID</dt>
|
||||
<dd id="id" th:text="${message.id}">123</dd>
|
||||
<dt>Date</dt>
|
||||
<dd id="created" th:text="${#calendars.format(message.created)}">
|
||||
July 11, 2012 2:17:16 PM CDT</dd>
|
||||
<dt>Summary</dt>
|
||||
<dd id="summary" th:text="${message.summary}">A short summary...
|
||||
</dd>
|
||||
<dt>Message</dt>
|
||||
<dd id="text" th:text="${message.text}">A detailed message that
|
||||
is longer than the summary.</dd>
|
||||
</dl>
|
||||
<div class="pull-left">
|
||||
<a href="messages" th:href="@{'/delete/' + ${message.id}}">
|
||||
delete </a> | <a href="form.html"
|
||||
th:href="@{'/modify/' + ${message.id}}"> modify </a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/**
|
||||
* A Basic Spring MVC Test for the Sample Controller"
|
||||
*
|
||||
* @author Biju Kunjummen
|
||||
* @author Doo-Hwan, Kwak
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration(classes = SampleWebThymeleaf3Application.class)
|
||||
public class MessageControllerWebTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext wac;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHome() throws Exception {
|
||||
this.mockMvc.perform(get("/")).andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("<title>Messages")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
this.mockMvc.perform(post("/").param("text", "FOO text").param("summary", "FOO"))
|
||||
.andExpect(status().isFound())
|
||||
.andExpect(header().string("location", RegexMatcher.matches("/[0-9]+")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateValidation() throws Exception {
|
||||
this.mockMvc.perform(post("/").param("text", "").param("summary", ""))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("is required")));
|
||||
}
|
||||
|
||||
private static class RegexMatcher extends TypeSafeMatcher<String> {
|
||||
private final String regex;
|
||||
|
||||
public RegexMatcher(String regex) {
|
||||
this.regex = regex;
|
||||
}
|
||||
|
||||
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
|
||||
return new RegexMatcher(regex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(String item) {
|
||||
return Pattern.compile(this.regex).matcher(item).find();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatchSafely(String item, Description mismatchDescription) {
|
||||
mismatchDescription.appendText("was \"").appendText(item).appendText("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("a string that matches regex: ")
|
||||
.appendText(this.regex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* 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 sample.web.thymeleaf3;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Basic integration tests for {@link SampleWebThymeleaf3Application}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class SampleWebThymeleaf3ApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
|
||||
@Test
|
||||
public void testHome() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("<title>Messages");
|
||||
assertThat(entity.getBody()).doesNotContain("layout:fragment");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
||||
map.set("text", "FOO text");
|
||||
map.set("summary", "FOO");
|
||||
URI location = this.restTemplate.postForLocation("/", map);
|
||||
assertThat(location.toString()).contains("localhost:" + this.port);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCss() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/css/bootstrap.min.css", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("body");
|
||||
}
|
||||
|
||||
}
|
@ -38,6 +38,16 @@
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web-thymeleaf3</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>thymeleaf</artifactId>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-facebook</artifactId>
|
||||
|
@ -38,6 +38,16 @@
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web-thymeleaf3</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>thymeleaf</artifactId>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-linkedin</artifactId>
|
||||
|
@ -38,6 +38,16 @@
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-web-thymeleaf3</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>thymeleaf</artifactId>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.social</groupId>
|
||||
<artifactId>spring-social-twitter</artifactId>
|
||||
|
@ -28,7 +28,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-spring4</artifactId>
|
||||
<artifactId>thymeleaf-spring5</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||
|
Loading…
Reference in New Issue
Block a user