Skip to content

Commit e42e9ec

Browse files
committed
initian revision - pendig cleanup of inherited artifacts
1 parent 36875f6 commit e42e9ec

15 files changed

Lines changed: 1026 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### Info
2+
3+
Static Spring boot Application hosting a basic AngularJS
4+
5+
custom form input validation example taken from __AngularJS Form Validation__ [article](https://www.geeksforgeeks.org/angularjs-form-validation/)
6+
7+
![Page](https://github.com/sergueik/springboot_study/blob/master/basic-angularjs-validation/screenshots/capture-page.png)
8+
9+
### NOTE:
10+
11+
the controller rule will override the existing static page:
12+
13+
add `src/main/resourcses/static/page.html`
14+
and endpoint
15+
```java
16+
@ResponseBody
17+
@GetMapping("/page")
18+
public String getPage() {
19+
return "page is here";
20+
}
21+
22+
```
23+
then
24+
```sh
25+
curl http://192.168.0.64:8080/page.html
26+
27+
```
28+
will return the text produced by controller:
29+
30+
```text
31+
page is here
32+
```
33+
### Testing
34+
```sh
35+
mvn -Ddebug=true -Dapplication=application test
36+
```
37+
38+
The `debug` flag will trigger printing additional debugging information
39+
40+
### Running
41+
```sh
42+
mvn clean -Dmaven.test.skip=true spring-boot:run
43+
```
44+
followed by opening in the browser
45+
46+
`curl http://localhost:8080/input-validation.html`
47+
this will show form with two inputs, validated. Only the second validation tiggels the button
48+
### See Also
49+
* AngularJS Form $setValidity [post](https://medium.com/@lily.lsps/angularjs-form-setvalidity-1f2485ad9b22)
50+
* `form.FormController` [documentation](https://docs.angularjs.org/api/ng/type/form.FormController)
51+
* https://stackoverflow.com/questions/14363656/using-setvalidity-inside-a-controller
52+
* [validating User Input on a Form in Angular JS](https://www.infragistics.com/community/blogs/b/dhananjay_kumar/posts/validating-user-input-on-a-form-in-angular-js)
53+
* https://stackoverflow.com/questions/42624184/how-to-call-any-function-in-input-type-text-in-angularjs
54+
### Author
55+
56+
[Serguei Kouzmine](kouzmine_serguei@yahoo.com)

basic-angularjs-validation/pom.xml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>example</groupId>
5+
<artifactId>angular-validator</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<name>basic-angular-validator</name>
9+
<description>Springboot Template page Demo project</description>
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>1.5.4.RELEASE</version>
14+
<relativePath/>
15+
</parent>
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
19+
<java.version>1.8</java.version>
20+
<finalName>${project.groupId}.${project.artifactId}</finalName>
21+
<jacoco-maven-plugin.version>0.8.6</jacoco-maven-plugin.version>
22+
<java.version>1.8</java.version>
23+
<maven.compiler.source>${java.version}</maven.compiler.source>
24+
<maven.compiler.target>${java.version}</maven.compiler.target>
25+
<failOnMissingWebXml>false</failOnMissingWebXml>
26+
<thymeleaf.version>3.0.8.RELEASE</thymeleaf.version>
27+
<thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf-extras-java8time.version>
28+
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
29+
<assertj.version>3.8.0</assertj.version>
30+
31+
<webjars-locator.version>0.30</webjars-locator.version>
32+
<webjars.bootstrap.version>3.3.7</webjars.bootstrap.version>
33+
<webjars.jquery.version>3.2.1</webjars.jquery.version>
34+
</properties>
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-devtools</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-web</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
47+
<!-- NOTE: after switchihg 1.5.4.RELEASE to 2.3.4.RELEASE
48+
[ERROR] Failed to execute goal on project static_page: Could not resolve dependencies for project
49+
Could not find artifact org.thymeleaf:thymeleaf-spring5:jar:3.0.6.RELEASE
50+
in central (https://repo.maven.apache.org/maven2)
51+
https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf-spring5
52+
-->
53+
</dependency>
54+
<dependency>
55+
<groupId>org.thymeleaf.extras</groupId>
56+
<artifactId>thymeleaf-extras-java8time</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-starter-actuator</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.webjars</groupId>
64+
<artifactId>bootstrap</artifactId>
65+
<version>${webjars.bootstrap.version}</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.webjars</groupId>
69+
<artifactId>jquery</artifactId>
70+
<version>${webjars.jquery.version}</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.webjars</groupId>
74+
<artifactId>webjars-locator</artifactId>
75+
<version>${webjars-locator.version}</version>
76+
<!-- NOTE: after switchihg 1.5.4.RELEASE to 2.3.4.RELEASE
77+
[ERROR] 'dependencies.dependency.version' for org.webjars:webjars-locator:jar is missing. @ line 64, column 17
78+
[ERROR]
79+
80+
-->
81+
</dependency>
82+
<!-- Test -->
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-starter-test</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.owasp.antisamy</groupId>
90+
<artifactId>antisamy</artifactId>
91+
<version>1.5.9</version>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.seleniumhq.selenium</groupId>
95+
<artifactId>selenium-java</artifactId>
96+
<version>3.13.0</version>
97+
<scope>test</scope>
98+
</dependency>
99+
</dependencies>
100+
<build>
101+
<sourceDirectory>src/main/java</sourceDirectory>
102+
<plugins>
103+
<plugin>
104+
<groupId>org.jacoco</groupId>
105+
<artifactId>jacoco-maven-plugin</artifactId>
106+
<version>${jacoco-maven-plugin.version}</version>
107+
<executions>
108+
<execution>
109+
<goals>
110+
<goal>prepare-agent</goal>
111+
</goals>
112+
</execution>
113+
<execution>
114+
<id>report</id>
115+
<phase>test</phase>
116+
<goals>
117+
<goal>report</goal>
118+
</goals>
119+
</execution>
120+
<execution>
121+
<id>jacoco-check</id>
122+
<goals>
123+
<goal>check</goal>
124+
</goals>
125+
<configuration>
126+
<rules>
127+
<rule>
128+
<element>PACKAGE</element>
129+
<limits>
130+
<limit>
131+
<counter>LINE</counter>
132+
<value>COVEREDRATIO</value>
133+
<minimum>${minimum.coverage}</minimum>
134+
</limit>
135+
</limits>
136+
</rule>
137+
</rules>
138+
</configuration>
139+
</execution>
140+
</executions>
141+
</plugin>
142+
<plugin>
143+
<groupId>org.springframework.boot</groupId>
144+
<artifactId>spring-boot-maven-plugin</artifactId>
145+
<configuration>
146+
<finalName>${finalName}</finalName>
147+
</configuration>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
</project>
10.2 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package example;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
// https://qna.habr.com/q/734991
6+
@SpringBootApplication
7+
public class Launcher {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Launcher.class, args);
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example;
2+
3+
import org.springframework.boot.builder.SpringApplicationBuilder;
4+
import org.springframework.boot.web.support.SpringBootServletInitializer;
5+
6+
public class ServletInitializer extends SpringBootServletInitializer {
7+
8+
@Override
9+
protected SpringApplicationBuilder configure(
10+
SpringApplicationBuilder application) {
11+
return application.sources(Launcher.class);
12+
}
13+
14+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package example.config;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
import org.springframework.format.FormatterRegistry;
11+
import org.springframework.http.converter.HttpMessageConverter;
12+
import org.springframework.scheduling.annotation.EnableAsync;
13+
import org.springframework.validation.MessageCodesResolver;
14+
import org.springframework.validation.Validator;
15+
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
16+
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
17+
import org.springframework.web.servlet.HandlerExceptionResolver;
18+
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
19+
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
20+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
21+
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
22+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
23+
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
24+
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
25+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
26+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
27+
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
28+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
29+
30+
@Configuration
31+
@EnableWebMvc
32+
public class Config implements WebMvcConfigurer {
33+
34+
// optional: adding the default locations
35+
// NOTE: every path has tobe mapped: non-mapped paths will be 404'ed
36+
// see the tests
37+
@Override
38+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
39+
40+
for (String dir : Arrays.asList("images", "css", "js", "")) {
41+
registry.addResourceHandler(String.format("/%s/**", dir))
42+
.addResourceLocations(String.format("classpath:/static/%s/", dir),
43+
String.format("file:///%s/src/main/resources/static/%s/",
44+
System.getProperty("user.dir").replaceAll("\\\\", "/"), dir));
45+
46+
}
47+
}
48+
49+
@Override
50+
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> arg0) {
51+
}
52+
53+
@Override
54+
public void addCorsMappings(CorsRegistry arg) {
55+
56+
}
57+
58+
@Override
59+
public void addFormatters(FormatterRegistry arg0) {
60+
61+
}
62+
63+
@Override
64+
public void addInterceptors(InterceptorRegistry arg0) {
65+
66+
}
67+
68+
@Override
69+
public void addReturnValueHandlers(
70+
List<HandlerMethodReturnValueHandler> arg0) {
71+
72+
}
73+
74+
@Override
75+
public void addViewControllers(ViewControllerRegistry arg0) {
76+
77+
}
78+
79+
@Override
80+
public void configureAsyncSupport(AsyncSupportConfigurer arg0) {
81+
82+
}
83+
84+
@Override
85+
public void configureContentNegotiation(ContentNegotiationConfigurer arg0) {
86+
87+
}
88+
89+
@Override
90+
public void configureDefaultServletHandling(
91+
DefaultServletHandlerConfigurer arg0) {
92+
93+
}
94+
95+
@Override
96+
public void configureHandlerExceptionResolvers(
97+
List<HandlerExceptionResolver> arg0) {
98+
99+
}
100+
101+
@Override
102+
public void configureMessageConverters(List<HttpMessageConverter<?>> arg0) {
103+
104+
}
105+
106+
@Override
107+
public void configurePathMatch(PathMatchConfigurer arg0) {
108+
109+
}
110+
111+
@Override
112+
public void configureViewResolvers(ViewResolverRegistry arg0) {
113+
114+
}
115+
116+
@Override
117+
public void extendHandlerExceptionResolvers(
118+
List<HandlerExceptionResolver> arg0) {
119+
120+
}
121+
122+
@Override
123+
public void extendMessageConverters(List<HttpMessageConverter<?>> arg0) {
124+
125+
}
126+
127+
@Override
128+
public MessageCodesResolver getMessageCodesResolver() {
129+
return null;
130+
}
131+
132+
@Override
133+
public Validator getValidator() {
134+
return null;
135+
}
136+
}

0 commit comments

Comments
 (0)