Skip to content

Commit 8388331

Browse files
committed
删除编译错误
1 parent f857c68 commit 8388331

243 files changed

Lines changed: 16741 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

web-modules/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Web
2+
3+
This module contains web modules.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Relevant Articles
2+
3+
- [Intro to Apache Tapestry](https://www.baeldung.com/apache-tapestry)
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>apache-tapestry</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<name>apache-tapestry</name>
9+
<packaging>war</packaging>
10+
11+
<parent>
12+
<groupId>com.baeldung</groupId>
13+
<artifactId>web-modules</artifactId>
14+
<version>1.0.0-SNAPSHOT</version>
15+
</parent>
16+
17+
<dependencies>
18+
<!-- To set up an application with a database, change the artifactId below to tapestry-hibernate, -->
19+
<!-- and add a dependency on your JDBC driver. You'll also need to add Hibernate configuration -->
20+
<!-- files, such as hibernate.cfg.xml. -->
21+
<dependency>
22+
<groupId>org.apache.tapestry</groupId>
23+
<artifactId>tapestry-core</artifactId>
24+
<version>${tapestry.version}</version>
25+
</dependency>
26+
<!-- Include the Log4j implementation for the SLF4J logging framework -->
27+
<dependency>
28+
<groupId>org.slf4j</groupId>
29+
<artifactId>slf4j-log4j12</artifactId>
30+
<version>${slf4j-release-version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.tapestry</groupId>
34+
<artifactId>tapestry-webresources</artifactId>
35+
<version>${tapestry.version}</version>
36+
</dependency>
37+
<!-- Uncomment this to add support for file uploads: -->
38+
<!-- <dependency> -->
39+
<!-- <groupId>org.apache.tapestry</groupId> -->
40+
<!-- <artifactId>tapestry-upload</artifactId> -->
41+
<!-- <version>${tapestry.version}</version> -->
42+
<!-- </dependency> -->
43+
<!-- A dependency on either JUnit or TestNG is required, or the surefire plugin (which runs the -->
44+
<!-- tests) will fail, preventing Maven from packaging the WAR. Tapestry includes a large number -->
45+
<!-- of testing facilities designed for use with TestNG (http://testng.org/), -->
46+
<!-- so it's recommended. -->
47+
<dependency>
48+
<groupId>org.testng</groupId>
49+
<artifactId>testng</artifactId>
50+
<version>${testng-release-version}</version>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.apache.tapestry</groupId>
55+
<artifactId>tapestry-test</artifactId>
56+
<version>${tapestry.version}</version>
57+
<scope>test</scope>
58+
</dependency>
59+
<!-- Provided by the servlet container, but sometimes referenced in the application code. -->
60+
<dependency>
61+
<groupId>javax.servlet</groupId>
62+
<artifactId>servlet-api</artifactId>
63+
<version>${servlet-api-release-version}</version>
64+
<scope>provided</scope>
65+
</dependency>
66+
<!-- Provide dependency to the Tapestry javadoc taglet which replaces the Maven component report -->
67+
<dependency>
68+
<groupId>org.apache.tapestry</groupId>
69+
<artifactId>tapestry-javadoc</artifactId>
70+
<version>${tapestry.version}</version>
71+
<scope>provided</scope>
72+
</dependency>
73+
</dependencies>
74+
75+
<build>
76+
<finalName>apache-tapestry</finalName>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-compiler-plugin</artifactId>
81+
<version>${compiler.plugin.version}</version>
82+
<configuration>
83+
<source>${source.version}</source>
84+
<target>${target.version}</target>
85+
<optimize>true</optimize>
86+
</configuration>
87+
</plugin>
88+
<plugin>
89+
<groupId>org.apache.maven.plugins</groupId>
90+
<artifactId>maven-surefire-plugin</artifactId>
91+
<version>${compiler.surefire.version}</version>
92+
<configuration>
93+
<systemPropertyVariables>
94+
<tapestry.execution-mode>Qa</tapestry.execution-mode>
95+
</systemPropertyVariables>
96+
</configuration>
97+
</plugin>
98+
<!-- Run the application using "mvn jetty:run" -->
99+
<plugin>
100+
<groupId>org.mortbay.jetty</groupId>
101+
<artifactId>maven-jetty-plugin</artifactId>
102+
<version>${compiler.jetty.version}</version>
103+
<configuration>
104+
<!-- Log to the console. -->
105+
<requestLog implementation="org.mortbay.jetty.NCSARequestLog">
106+
<!-- This doesn't do anything for Jetty, but is a workaround -->
107+
<!-- for a Maven bug that prevents the requestLog from being set. -->
108+
<append>true</append>
109+
</requestLog>
110+
<systemProperties>
111+
<systemProperty>
112+
<name>tapestry.execution-mode</name>
113+
<value>development</value>
114+
</systemProperty>
115+
</systemProperties>
116+
</configuration>
117+
</plugin>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-war-plugin</artifactId>
121+
<version>3.3.1</version>
122+
<configuration>
123+
<archive>
124+
<manifest>
125+
<addClasspath>true</addClasspath>
126+
</manifest>
127+
</archive>
128+
</configuration>
129+
</plugin>
130+
</plugins>
131+
</build>
132+
133+
<repositories>
134+
<repository>
135+
<id>jboss</id>
136+
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
137+
</repository>
138+
</repositories>
139+
140+
<properties>
141+
<compiler.jetty.version>6.1.16</compiler.jetty.version>
142+
<compiler.surefire.version>3.0.0-M5</compiler.surefire.version>
143+
<compiler.plugin.version>3.8.1</compiler.plugin.version>
144+
<source.version>11</source.version>
145+
<target.version>11</target.version>
146+
<tapestry.version>5.8.2</tapestry.version>
147+
<servlet-api-release-version>2.5</servlet-api-release-version>
148+
<testng-release-version>6.8.21</testng-release-version>
149+
<slf4j-release-version>1.7.19</slf4j-release-version>
150+
</properties>
151+
152+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.baeldung.tapestry.components;
2+
3+
import org.apache.tapestry5.BindingConstants;
4+
import org.apache.tapestry5.annotations.Parameter;
5+
import org.apache.tapestry5.annotations.Property;
6+
7+
/**
8+
* Layout component for pages of application.
9+
*/
10+
public class Layout {
11+
12+
@Property
13+
@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
14+
private String title;
15+
16+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.baeldung.tapestry.pages;
2+
3+
public class Error404 {
4+
5+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baeldung.tapestry.pages;
2+
3+
import java.util.Date;
4+
5+
import org.apache.tapestry5.Block;
6+
import org.apache.tapestry5.annotations.Log;
7+
import org.apache.tapestry5.annotations.Property;
8+
import org.apache.tapestry5.ioc.annotations.Inject;
9+
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
10+
import org.slf4j.Logger;
11+
12+
public class Home {
13+
14+
@Property
15+
private String appName = "apache-tapestry";
16+
17+
public Date getCurrentTime() {
18+
return new Date();
19+
}
20+
21+
@Inject
22+
private Logger logger;
23+
24+
@Inject
25+
private AjaxResponseRenderer ajaxResponseRenderer;
26+
27+
@Inject
28+
private Block ajaxBlock;
29+
30+
@Log
31+
void onCallAjax() {
32+
logger.info("Ajax call");
33+
ajaxResponseRenderer.addRender("ajaxZone", ajaxBlock);
34+
}
35+
36+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.baeldung.tapestry.pages;
2+
3+
4+
import org.apache.tapestry5.Block;
5+
import org.apache.tapestry5.EventContext;
6+
import org.apache.tapestry5.SymbolConstants;
7+
import org.apache.tapestry5.annotations.InjectPage;
8+
import org.apache.tapestry5.annotations.Log;
9+
import org.apache.tapestry5.annotations.Property;
10+
import org.apache.tapestry5.ioc.annotations.Inject;
11+
import org.apache.tapestry5.ioc.annotations.Symbol;
12+
import org.apache.tapestry5.services.HttpError;
13+
import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
14+
import org.slf4j.Logger;
15+
16+
import java.util.Date;
17+
18+
/**
19+
* Start page of application apache-tapestry.
20+
*/
21+
public class Index {
22+
@Inject
23+
private Logger logger;
24+
25+
@Inject
26+
private AjaxResponseRenderer ajaxResponseRenderer;
27+
28+
@Property
29+
@Inject
30+
@Symbol(SymbolConstants.TAPESTRY_VERSION)
31+
private String tapestryVersion;
32+
33+
@Inject
34+
private Block block;
35+
36+
// Handle call with an unwanted context
37+
Object onActivate(EventContext eventContext) {
38+
return eventContext.getCount() > 0 ?
39+
new HttpError(404, "Resource not found") :
40+
null;
41+
}
42+
43+
@Log
44+
void onComplete() {
45+
logger.info("Complete call on Index page");
46+
}
47+
48+
@Log
49+
void onAjax() {
50+
logger.info("Ajax call on Index page");
51+
52+
ajaxResponseRenderer.addRender("middlezone", block);
53+
}
54+
55+
public Date getCurrentTime() {
56+
return new Date();
57+
}
58+
59+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.baeldung.tapestry.pages;
2+
3+
import org.apache.tapestry5.alerts.AlertManager;
4+
import org.apache.tapestry5.annotations.InjectComponent;
5+
import org.apache.tapestry5.annotations.Property;
6+
import org.apache.tapestry5.corelib.components.Form;
7+
import org.apache.tapestry5.ioc.annotations.Inject;
8+
import org.slf4j.Logger;
9+
10+
public class Login {
11+
@Inject
12+
private Logger logger;
13+
14+
@Inject
15+
private AlertManager alertManager;
16+
17+
@InjectComponent
18+
private Form login;
19+
20+
@Property
21+
private String email;
22+
23+
@Property
24+
private String password;
25+
26+
void onValidateFromLogin() {
27+
if(email == null || password == null) {
28+
alertManager.error("Email/Password is null");
29+
login.recordError("Validation failed");
30+
}
31+
}
32+
33+
Object onSuccessFromLogin() {
34+
alertManager.success("Welcome! Login Successful");
35+
return Home.class;
36+
}
37+
38+
void onFailureFromLogin() {
39+
alertManager.error("Please try again with correct credentials");
40+
}
41+
42+
}

0 commit comments

Comments
 (0)