mirror of
https://github.com/apache/struts.git
synced 2026-08-08 08:07:17 +00:00
Compare commits
229 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fb9aba74b | |||
| c45664a330 | |||
| 91c9314176 | |||
| a4e9902d94 | |||
| fe5b197738 | |||
| 87e322dbe2 | |||
| 7909f43237 | |||
| 1fe822cca0 | |||
| ef90b3ba3c | |||
| d35ec15c76 | |||
| 583b174fe6 | |||
| 9b044377ac | |||
| 58f37babbf | |||
| fe3dd6ba9f | |||
| 7a77c7a82c | |||
| 5038a9209f | |||
| 2135ebf651 | |||
| c0dd8dd80c | |||
| c36eafa37a | |||
| 07603b9591 | |||
| 3227d5929a | |||
| 4a8ddbb274 | |||
| 67ba458d03 | |||
| 959b2182b2 | |||
| 6de93e77db | |||
| 59dc9301e0 | |||
| 2fc4a822a4 | |||
| 6a6270f62a | |||
| 9153228b6a | |||
| 5713a74edc | |||
| 32071c71ad | |||
| 7e4791985b | |||
| 3c1e44ca2d | |||
| 2ba8d97ad0 | |||
| cba0db0b07 | |||
| 688162cae2 | |||
| a33c162f53 | |||
| c7a6daf5ce | |||
| 370c7ce17a | |||
| 55989befce | |||
| 2e4a4b5e36 | |||
| 9d07c3b4c3 | |||
| 575e4e8c9b | |||
| 74388dfba7 | |||
| 4ee8b02262 | |||
| c8febc2050 | |||
| 3ea126388c | |||
| 09993e3476 | |||
| f5688e680b | |||
| 60a3db0a63 | |||
| 4714d27678 | |||
| 4feceee5f1 | |||
| 1f5305c249 | |||
| 1903e0ef33 | |||
| 8a2f494c12 | |||
| 6b2e5ecd9b | |||
| cb08d18b5a | |||
| 1e2517b59e | |||
| 8d6ecee849 | |||
| 570bf46a7f | |||
| be82a72403 | |||
| 6fbd9e5321 | |||
| b0a4c4f417 | |||
| b001c61f89 | |||
| 2beac8eba4 | |||
| d351843ecd | |||
| 22036174c7 | |||
| ced44650ec | |||
| 1908cbab8f | |||
| c176390926 | |||
| fe46ad9f4a | |||
| a0dc19c4be | |||
| 7cdcd84b83 | |||
| 8566c14648 | |||
| c75ddbbf3e | |||
| b15dc458cf | |||
| 3f74923099 | |||
| 5b2f63fa7e | |||
| d9d580ae3d | |||
| 67e0477993 | |||
| 89bcbecc70 | |||
| 67ee1b2d67 | |||
| 5b81ec0852 | |||
| 266cd1333c | |||
| 323267fa88 | |||
| 2432449975 | |||
| 45a1f5efc6 | |||
| b488c80aa2 | |||
| 144010c3b7 | |||
| 9b87e88bb0 | |||
| 117e84f246 | |||
| a28f22605c | |||
| deb6c09bce | |||
| f95f9a7cd3 | |||
| 9e23fbe665 | |||
| a623842bce | |||
| 2757c23572 | |||
| ebedd7391f | |||
| 7ce8f484e0 | |||
| dfd07190bd | |||
| 111bc25650 | |||
| 8ba8ee5fe6 | |||
| 14bd4b80cf | |||
| bbca2717f9 | |||
| b622e5d725 | |||
| efa447af21 | |||
| cf6cbf3816 | |||
| 48ee44bbc2 | |||
| b18fbda1f7 | |||
| 28c8f1503d | |||
| d1695f7a4d | |||
| b359da5517 | |||
| 36a890ba69 | |||
| e3fbe88355 | |||
| 272c2e7bba | |||
| 60095a6934 | |||
| ae9dc42da7 | |||
| 8da6a79926 | |||
| 7deb481298 | |||
| 9f2770b2c3 | |||
| 78451db87e | |||
| 49ddf6130a | |||
| 1bcadd4682 | |||
| b115a510a6 | |||
| fbab5d4df9 | |||
| cd7f1097e2 | |||
| 2eff2da4fd | |||
| b3629460e6 | |||
| 3528b88327 | |||
| 3e04197ba7 | |||
| 09eb286020 | |||
| d33be1d43c | |||
| c812450292 | |||
| 75cc664fda | |||
| 9d903ddf96 | |||
| 4ccde0087e | |||
| 7473b4cef9 | |||
| 0bd4266d2f | |||
| 48c4e3b6a0 | |||
| 40b4395801 | |||
| 0ce2c7b5dd | |||
| 2924208228 | |||
| 3c71b2ed8c | |||
| d7626ed7d6 | |||
| fda2c546b3 | |||
| f03d36c46b | |||
| 90f984ca85 | |||
| 0f83b83972 | |||
| c352fb59c1 | |||
| 3d155048da | |||
| 9a06e7c983 | |||
| 280c3e4f5f | |||
| 4c95983abb | |||
| 3111c4b86f | |||
| efab3fc6fa | |||
| 0c69993cd7 | |||
| b04ad6b412 | |||
| 735d1bc88d | |||
| f388f6a679 | |||
| e74d21befb | |||
| 93c9856527 | |||
| f05a4d1c83 | |||
| e4872ecf8e | |||
| f6a60fc66f | |||
| 00f0942449 | |||
| 8c7c39424f | |||
| ad7f3e3523 | |||
| 5a50bd312d | |||
| 5b68d4bd59 | |||
| 64a3d0c32f | |||
| 6f135ea4d8 | |||
| bdace9bbad | |||
| 9765edf2ea | |||
| e81adc11eb | |||
| 0d84319dbf | |||
| 9b259ae43a | |||
| 0fd85517e9 | |||
| 8d07694be6 | |||
| d42e530c89 | |||
| ea9d4774dd | |||
| 9948258fca | |||
| 8bbe215b6a | |||
| 90fca13568 | |||
| d2d222e05d | |||
| dc03a83f61 | |||
| c067e25b2c | |||
| acd6ebeb6b | |||
| 89154e0479 | |||
| 107810dce2 | |||
| 1536a7e04b | |||
| 663dd3a50c | |||
| 6caa932fff | |||
| a4464099d9 | |||
| 932eed204d | |||
| e7cce1bcd7 | |||
| 9280a478c3 | |||
| adbfab8cf1 | |||
| b8da13c235 | |||
| 0d3358b035 | |||
| 935868c756 | |||
| 479a9d86ed | |||
| eeb1d8e0ca | |||
| e3e854a67b | |||
| 7e5e49e811 | |||
| 8c10a303d0 | |||
| dbd74ae3a3 | |||
| f977f0c0e5 | |||
| d6e30b45da | |||
| 9195990b56 | |||
| 0c4d66430e | |||
| de0b3204ec | |||
| cec46792cf | |||
| 6d0fc2aa28 | |||
| 1f46802ba2 | |||
| 085471b408 | |||
| 9ea9d566df | |||
| 5372aff1dd | |||
| 92fc324f27 | |||
| b7b5bff13a | |||
| 27e4d0d47a | |||
| cb62cb4e9a | |||
| abfb2f4568 | |||
| e9a1668199 | |||
| 8b4c188d0f | |||
| f9953938f7 | |||
| 10edbce8d9 | |||
| 56c1291d2f | |||
| fcc2c9d3ab | |||
| 54e387dc6f |
@@ -11,9 +11,19 @@ notifications:
|
||||
jira_options: link label worklog
|
||||
|
||||
github:
|
||||
description: "Apache Struts is a free, open-source, MVC framework for creating elegant, modern Java web applications"
|
||||
homepage: https://struts.apache.org/
|
||||
del_branch_on_merge: true
|
||||
protected_branches:
|
||||
master:
|
||||
main:
|
||||
# contexts are the names of checks that must pass.
|
||||
contexts:
|
||||
- build
|
||||
required_pull_request_reviews:
|
||||
# it does not work because our github teams are private/secret, see INFRA-25666
|
||||
require_code_owner_reviews: false
|
||||
required_approving_review_count: 0
|
||||
release/*:
|
||||
# contexts are the names of checks that must pass.
|
||||
contexts:
|
||||
- build
|
||||
|
||||
@@ -17,7 +17,8 @@ name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
branches:
|
||||
- 'release/*'
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
@@ -41,15 +42,21 @@ jobs:
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
cache: 'maven'
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.28.8
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3.28.8
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.28.8
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # 2.3.3
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # 2.4.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -57,13 +57,13 @@ jobs:
|
||||
publish_results: true
|
||||
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # 4.3.4
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@03e7845b7bfcd5e7fb63d1ae8c61b0e791134fab # 2.22.11
|
||||
uses: github/codeql-action/upload-sarif@acb9cb18eec7e3a113ef83cff0be91e75cfd9526 # 2.22.11
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
Vendored
+11
-54
@@ -69,7 +69,7 @@ pipeline {
|
||||
stages {
|
||||
stage('Test & Coverage') {
|
||||
steps {
|
||||
sh './mvnw -B verify -Pcoverage -DskipAssembly --no-transfer-progress'
|
||||
sh './mvnw -B verify -Pcoverage -DskipAssembly'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
@@ -81,58 +81,15 @@ pipeline {
|
||||
stage('Code Quality') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'master'; branch 'release/struts-7-0-x'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'asf-struts-sonarcloud', variable: 'SONARCLOUD_TOKEN')]) {
|
||||
sh './mvnw -B -Pcoverage -DskipAssembly -Dsonar.login=${SONARCLOUD_TOKEN} verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar --no-transfer-progress'
|
||||
sh './mvnw -B -Pcoverage -DskipAssembly -Dsonar.login=${SONARCLOUD_TOKEN} verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Source & JavaDoc') {
|
||||
when {
|
||||
branch 'release/struts-7-0-x'
|
||||
}
|
||||
steps {
|
||||
dir("local-snapshots-dir/") {
|
||||
deleteDir()
|
||||
}
|
||||
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly --no-transfer-progress'
|
||||
}
|
||||
}
|
||||
stage('Deploy Snapshot') {
|
||||
when {
|
||||
branch 'release/struts-7-0-x'
|
||||
}
|
||||
steps {
|
||||
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
|
||||
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly --no-transfer-progress'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Upload nightlies') {
|
||||
when {
|
||||
branch 'release/struts-7-0-x'
|
||||
}
|
||||
steps {
|
||||
sh './mvnw -B package -DskipTests --no-transfer-progress'
|
||||
sshPublisher(publishers: [
|
||||
sshPublisherDesc(
|
||||
configName: 'Nightlies',
|
||||
transfers: [
|
||||
sshTransfer(
|
||||
remoteDirectory: '/struts/snapshot',
|
||||
removePrefix: 'assembly/target/assembly/out',
|
||||
sourceFiles: 'assembly/target/assembly/out/struts-*.zip',
|
||||
cleanRemote: true
|
||||
)
|
||||
],
|
||||
verbose: true
|
||||
)
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
@@ -154,12 +111,12 @@ pipeline {
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh './mvnw -B clean install -DskipTests -DskipAssembly --no-transfer-progress'
|
||||
sh './mvnw -B clean install -DskipTests -DskipAssembly'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh './mvnw -B verify --no-transfer-progress'
|
||||
sh './mvnw -B verify -DskipAssembly'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
@@ -170,31 +127,31 @@ pipeline {
|
||||
}
|
||||
stage('Build Source & JavaDoc') {
|
||||
when {
|
||||
branch 'master'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
dir("local-snapshots-dir/") {
|
||||
deleteDir()
|
||||
}
|
||||
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly --no-transfer-progress'
|
||||
sh './mvnw -B source:jar javadoc:jar -DskipTests -DskipAssembly'
|
||||
}
|
||||
}
|
||||
stage('Deploy Snapshot') {
|
||||
when {
|
||||
branch 'master'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
|
||||
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly --no-transfer-progress'
|
||||
sh './mvnw -s \${CUSTOM_SETTINGS} deploy -DskipTests -DskipAssembly'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Upload nightlies') {
|
||||
when {
|
||||
branch 'master'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
sh './mvnw -B package -DskipTests --no-transfer-progress'
|
||||
sh './mvnw -B package -DskipTests'
|
||||
sshPublisher(publishers: [
|
||||
sshPublisherDesc(
|
||||
configName: 'Nightlies',
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
<name>Struts 2 Rest Showcase Webapp</name>
|
||||
<description>Struts 2 Rest Showcase Example</description>
|
||||
|
||||
|
||||
@@ -18,30 +18,30 @@
|
||||
*/
|
||||
package org.demo.rest.example;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.rest.DefaultHttpHeaders;
|
||||
import org.apache.struts2.rest.HttpHeaders;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import com.opensymphony.xwork2.ValidationAwareSupport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.rest.DefaultHttpHeaders;
|
||||
import org.apache.struts2.rest.HttpHeaders;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Results({
|
||||
@Result(name="success", type="redirectAction", params = {"actionName" , "orders"})
|
||||
})
|
||||
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable{
|
||||
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, Validateable {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(OrdersController.class);
|
||||
|
||||
private Order model = new Order();
|
||||
private String id;
|
||||
private Collection<Order> list;
|
||||
private OrdersService ordersService = new OrdersService();
|
||||
private final OrdersService ordersService = new OrdersService();
|
||||
|
||||
// GET /orders/1
|
||||
public HttpHeaders show() {
|
||||
@@ -54,7 +54,7 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
|
||||
return new DefaultHttpHeaders("index")
|
||||
.disableCaching();
|
||||
}
|
||||
|
||||
|
||||
// GET /orders/1/edit
|
||||
public String edit() {
|
||||
return "edit";
|
||||
@@ -101,13 +101,15 @@ public class OrdersController extends ValidationAwareSupport implements ModelDri
|
||||
}
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setId(String id) {
|
||||
if (id != null) {
|
||||
this.model = ordersService.get(id);
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getModel() {
|
||||
return (list != null ? list : model);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
*/
|
||||
package org.demo.rest.example;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OrdersService {
|
||||
|
||||
private static Map<String,Order> orders = new HashMap<String,Order>();
|
||||
private static final Map<String,Order> orders = new HashMap<>();
|
||||
private static int nextId = 6;
|
||||
static {
|
||||
orders.put("3", new Order("3", "Bob", 33));
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
@@ -137,6 +137,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
@@ -157,7 +163,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>it.org.apache.struts2.showcase.*Test</include>
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
//START SNIPPET: treeExampleDynamicJavaSelected
|
||||
@@ -30,7 +31,7 @@ public class DynamicTreeSelectAction extends ActionSupport {
|
||||
private long nodeId;
|
||||
private Category currentCategory;
|
||||
|
||||
|
||||
@StrutsParameter
|
||||
public void setNodeId(long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
+16
-1
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -74,6 +75,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteCartoonCharactersKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
|
||||
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
|
||||
}
|
||||
@@ -82,6 +84,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _notFavouriteCartoonCharactersKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
|
||||
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
|
||||
}
|
||||
@@ -108,6 +111,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteCarsKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteCars(List favouriteCars) {
|
||||
_favouriteCarsKeys = favouriteCars;
|
||||
}
|
||||
@@ -116,6 +120,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _notFavouriteCarsKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNotFavouriteCars(List notFavouriteCars) {
|
||||
_notFavouriteCarsKeys = notFavouriteCars;
|
||||
}
|
||||
@@ -142,6 +147,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteMotorcyclesKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
|
||||
_favouriteMotorcyclesKeys = favouriteMotorcycles;
|
||||
}
|
||||
@@ -150,6 +156,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _notFavouriteMotorcyclesKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
|
||||
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
|
||||
}
|
||||
@@ -176,6 +183,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteCountriesKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteCountries(List favouriteCountries) {
|
||||
_favouriteCountriesKeys = favouriteCountries;
|
||||
}
|
||||
@@ -184,6 +192,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _notFavouriteCountriesKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNotFavouriteCountries(List notFavouriteCountries) {
|
||||
_notFavouriteCountriesKeys = notFavouriteCountries;
|
||||
}
|
||||
@@ -205,6 +214,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteSportsKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteSports(List favouriteSportsKeys) {
|
||||
this._favouriteSportsKeys = favouriteSportsKeys;
|
||||
}
|
||||
@@ -213,6 +223,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _nonFavouriteSportsKeys;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNonFavouriteSports(List notFavouriteSportsKeys) {
|
||||
this._nonFavouriteSportsKeys = notFavouriteSportsKeys;
|
||||
}
|
||||
@@ -222,6 +233,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
@@ -230,6 +242,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
@@ -239,6 +252,7 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
@@ -264,12 +278,13 @@ public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
return _favouriteCities;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteCities(List favouriteCities) {
|
||||
this._favouriteCities = favouriteCities;
|
||||
}
|
||||
|
||||
// actions
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+6
-1
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -36,6 +37,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
|
||||
return this.description1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDescription1(String description1) {
|
||||
this.description1 = description1;
|
||||
}
|
||||
@@ -45,6 +47,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
|
||||
return this.description2;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDescription2(String description2) {
|
||||
this.description2 = description2;
|
||||
}
|
||||
@@ -54,6 +57,7 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
|
||||
return this.description3;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDescription3(String description3) {
|
||||
this.description3 = description3;
|
||||
}
|
||||
@@ -63,11 +67,12 @@ public class LotsOfRichtexteditorAction extends ActionSupport {
|
||||
return this.description4;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDescription4(String description4) {
|
||||
this.description4 = description4;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -75,11 +76,11 @@ public class MoreSelectsAction extends ActionSupport {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCartoonCharacters() {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
@@ -88,15 +89,16 @@ public class MoreSelectsAction extends ActionSupport {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCountries() {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
@@ -105,6 +107,7 @@ public class MoreSelectsAction extends ActionSupport {
|
||||
return favouriteNumbers;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteNumbers(List favouriteNumbers) {
|
||||
this.favouriteNumbers = favouriteNumbers;
|
||||
}
|
||||
@@ -129,12 +132,13 @@ public class MoreSelectsAction extends ActionSupport {
|
||||
return favouriteCities;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setFavouriteCities(List favouriteCities) {
|
||||
this.favouriteCities = favouriteCities;
|
||||
}
|
||||
|
||||
// actions
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
public class ShowAjaxDynamicTreeAction extends ActionSupport {
|
||||
@@ -34,6 +35,7 @@ public class ShowAjaxDynamicTreeAction extends ActionSupport {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setNodeId(int nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
@@ -200,6 +200,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
return bestFriend;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setBestFriend(String bestFriend) {
|
||||
this.bestFriend = bestFriend;
|
||||
}
|
||||
@@ -231,6 +232,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPicture(File picture) {
|
||||
this.picture = picture;
|
||||
}
|
||||
@@ -239,10 +241,12 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
return this.picture;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPictureContentType(String pictureContentType) {
|
||||
this.pictureContentType = pictureContentType;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setPictureFileName(String pictureFileName) {
|
||||
this.pictureFileName = pictureFileName;
|
||||
}
|
||||
@@ -323,6 +327,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof VehicalType)) {
|
||||
return false;
|
||||
@@ -331,6 +336,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
@@ -354,6 +360,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof VehicalSpecific)) {
|
||||
return false;
|
||||
@@ -362,6 +369,7 @@ public class UITagExample extends ActionSupport implements Validateable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
|
||||
+51
-50
@@ -21,6 +21,7 @@ package org.apache.struts2.showcase.action;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.dao.Dao;
|
||||
import org.apache.struts2.showcase.model.IdEntity;
|
||||
|
||||
@@ -33,62 +34,62 @@ import java.util.Collection;
|
||||
|
||||
public abstract class AbstractCRUDAction extends ActionSupport {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
|
||||
private static final Logger log = LogManager.getLogger(AbstractCRUDAction.class);
|
||||
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
|
||||
protected abstract Dao getDao();
|
||||
protected abstract Dao getDao();
|
||||
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
@StrutsParameter
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count = 0;
|
||||
for (String s : toDelete) {
|
||||
count = count + getDao().delete(s);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: {} items deleted.", count);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count = 0;
|
||||
for (int i = 0, j = toDelete.length; i < j; i++) {
|
||||
count = count + getDao().delete(toDelete[i]);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.apache.struts2.showcase.action;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.application.TestDataProvider;
|
||||
import org.apache.struts2.showcase.dao.Dao;
|
||||
import org.apache.struts2.showcase.dao.EmployeeDao;
|
||||
@@ -52,7 +53,7 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
|
||||
|
||||
public String execute() throws Exception {
|
||||
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
|
||||
setSelectedSkills(new ArrayList<String>());
|
||||
setSelectedSkills(new ArrayList<>());
|
||||
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
|
||||
while (it.hasNext()) {
|
||||
getSelectedSkills().add(((Skill) it.next()).getName());
|
||||
@@ -73,10 +74,12 @@ public class EmployeeAction extends AbstractCRUDAction implements Preparable {
|
||||
return empId;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setEmpId(Long empId) {
|
||||
this.empId = empId;
|
||||
}
|
||||
|
||||
@StrutsParameter(depth = 2)
|
||||
public Employee getCurrentEmployee() {
|
||||
return currentEmployee;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ package org.apache.struts2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExampleAction extends ActionSupport {
|
||||
public static final String CONSTANT = "Struts Rocks!";
|
||||
@@ -46,7 +50,7 @@ public class ExampleAction extends ActionSupport {
|
||||
}
|
||||
|
||||
public Map<String, Book> getBooks() {
|
||||
Map<String, Book> books = new HashMap<String, Book>();
|
||||
Map<String, Book> books = new HashMap<>();
|
||||
books.put("Iliad", new Book("Iliad", "Homer"));
|
||||
books.put("The Republic", new Book("The Replublic", "Plato"));
|
||||
books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
|
||||
@@ -79,4 +83,4 @@ class Book {
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,13 @@ package org.apache.struts2.showcase.action;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.After;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
@@ -62,6 +67,7 @@ public class JSPEvalAction extends ExampleAction {
|
||||
}
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setJsp(String jsp) {
|
||||
this.jsp = jsp;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
@Override
|
||||
public void prepare() throws Exception {
|
||||
Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill());
|
||||
if (preFetched != null) {
|
||||
@@ -64,6 +65,7 @@ public class SkillAction extends AbstractCRUDAction implements Preparable {
|
||||
return skillName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
}
|
||||
|
||||
+3
@@ -19,6 +19,7 @@
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain1 extends ActionSupport {
|
||||
|
||||
@@ -26,6 +27,7 @@ public class ActionChain1 extends ActionSupport {
|
||||
|
||||
private String actionChain1Property1 = "Property Set In Action Chain 1";
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -34,6 +36,7 @@ public class ActionChain1 extends ActionSupport {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
+4
-1
@@ -19,6 +19,7 @@
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain2 extends ActionSupport {
|
||||
|
||||
@@ -27,6 +28,7 @@ public class ActionChain2 extends ActionSupport {
|
||||
private String actionChain1Property1;
|
||||
private String actionChain2Property1 = "Property Set in Action Chain 2";
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -35,15 +37,16 @@ public class ActionChain2 extends ActionSupport {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
|
||||
+5
-3
@@ -19,6 +19,7 @@
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain3 extends ActionSupport {
|
||||
|
||||
@@ -28,7 +29,7 @@ public class ActionChain3 extends ActionSupport {
|
||||
private String actionChain2Property1;
|
||||
private String actionChain3Property1 = "Property set in Action Chain 3";
|
||||
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -37,24 +38,25 @@ public class ActionChain3 extends ActionSupport {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain3Property1() {
|
||||
return actionChain3Property1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setActionChain3Property1(String actionChain3Property1) {
|
||||
this.actionChain3Property1 = actionChain3Property1;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class AjaxTestAction implements Action, Serializable {
|
||||
|
||||
private static int counter = 0;
|
||||
@@ -46,6 +46,7 @@ public class AjaxTestAction implements Action, Serializable {
|
||||
return data;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
+4
-1
@@ -21,16 +21,18 @@
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AutocompleterExampleAction extends ActionSupport {
|
||||
private String select;
|
||||
private List<String> options = new ArrayList<String>();
|
||||
private final List<String> options = new ArrayList<>();
|
||||
|
||||
private static final long serialVersionUID = -8481638176160014396L;
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
if ("fruits".equals(select)) {
|
||||
options.add("apple");
|
||||
@@ -49,6 +51,7 @@ public class AutocompleterExampleAction extends ActionSupport {
|
||||
return select;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSelect(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
+3
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -51,6 +52,7 @@ public class Example4ShowPanelAction extends ActionSupport {
|
||||
return gender;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public class Example4ShowPanelAction extends ActionSupport {
|
||||
return name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class Example5Action extends ActionSupport {
|
||||
|
||||
@@ -37,6 +38,7 @@ public class Example5Action extends ActionSupport {
|
||||
return name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -45,6 +47,7 @@ public class Example5Action extends ActionSupport {
|
||||
return age;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.ajax.tree;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -28,6 +29,7 @@ public class GetCategory extends ActionSupport {
|
||||
private long catId;
|
||||
private Category category;
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
if (catId < 1) {
|
||||
// force the root
|
||||
@@ -39,6 +41,7 @@ public class GetCategory extends ActionSupport {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setCatId(long catId) {
|
||||
this.catId = catId;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ package org.apache.struts2.showcase.ajax.tree;
|
||||
/**
|
||||
*/
|
||||
public class Toggle extends GetCategory {
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
super.execute();
|
||||
|
||||
|
||||
@@ -50,15 +50,12 @@ public class ChatRoomAction extends ActionSupport {
|
||||
}
|
||||
|
||||
public Callable<String> receiveNewMessages() throws Exception {
|
||||
return new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
while (lastIndex >= messages.size()) {
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
newMessages = messages.subList(lastIndex, messages.size());
|
||||
return SUCCESS;
|
||||
return () -> {
|
||||
while (lastIndex >= messages.size()) {
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
newMessages = messages.subList(lastIndex, messages.size());
|
||||
return SUCCESS;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
|
||||
public class ChatLoginAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -43,6 +43,7 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class CrudRoomAction extends ActionSupport {
|
||||
|
||||
@@ -36,6 +37,7 @@ public class CrudRoomAction extends ActionSupport {
|
||||
return description;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
@@ -44,6 +46,7 @@ public class CrudRoomAction extends ActionSupport {
|
||||
return name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
|
||||
public class EnterRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -38,6 +38,7 @@ public class EnterRoomAction extends ActionSupport implements SessionAware {
|
||||
return this.roomName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
|
||||
public class ExitRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -38,6 +38,7 @@ public class ExitRoomAction extends ActionSupport implements SessionAware {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
+4
-2
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,13 +31,14 @@ public class MessagesAvailableInRoomAction extends ActionSupport {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String roomName;
|
||||
private ChatService chatService;
|
||||
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
|
||||
private final ChatService chatService;
|
||||
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<>();
|
||||
|
||||
public String getRoomName() {
|
||||
return this.roomName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
+6
-4
@@ -21,16 +21,16 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
|
||||
public class SendMessageToRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private final ChatService chatService;
|
||||
|
||||
private String roomName;
|
||||
private String message;
|
||||
@@ -45,6 +45,7 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
|
||||
return this.roomName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
@@ -53,11 +54,12 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
try {
|
||||
|
||||
+5
-2
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,8 +30,8 @@ public class UsersAvailableInRoomAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private List<User> usersAvailableInRoom = new ArrayList<User>();
|
||||
private final ChatService chatService;
|
||||
private List<User> usersAvailableInRoom = new ArrayList<>();
|
||||
|
||||
private String roomName;
|
||||
|
||||
@@ -43,6 +44,7 @@ public class UsersAvailableInRoomAction extends ActionSupport {
|
||||
return this.roomName;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
@@ -51,6 +53,7 @@ public class UsersAvailableInRoomAction extends ActionSupport {
|
||||
return usersAvailableInRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
|
||||
|
||||
+1
-2
@@ -34,7 +34,7 @@ public class OperationsEnumAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -2229489704988870318L;
|
||||
|
||||
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
|
||||
private List<OperationsEnum> selectedOperations = new LinkedList<>();
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
@@ -53,7 +53,6 @@ public class OperationsEnumAction extends ActionSupport {
|
||||
this.selectedOperations = selectedOperations;
|
||||
}
|
||||
|
||||
|
||||
public List<OperationsEnum> getAvailableOperations() {
|
||||
return Arrays.asList(OperationsEnum.values());
|
||||
}
|
||||
|
||||
+6
@@ -37,6 +37,7 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
|
||||
private String fileName;
|
||||
private String caption;
|
||||
private String originalName;
|
||||
private String inputName;
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
@@ -58,6 +59,10 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
|
||||
return originalName;
|
||||
}
|
||||
|
||||
public String getInputName() {
|
||||
return inputName;
|
||||
}
|
||||
|
||||
public Object getUploadedFile() {
|
||||
return uploadedFile.getContent();
|
||||
}
|
||||
@@ -85,5 +90,6 @@ public class FileUploadAction extends ActionSupport implements UploadedFilesAwar
|
||||
this.fileName = uploadedFile.getName();
|
||||
this.contentType = uploadedFile.getContentType();
|
||||
this.originalName = uploadedFile.getOriginalName();
|
||||
this.inputName = uploadedFile.getInputName();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -28,12 +28,16 @@ import org.apache.struts2.dispatcher.multipart.UploadedFile;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Showcase action - mutiple file upload using array.
|
||||
* Showcase action - multiple file upload using array.
|
||||
*/
|
||||
public class MultipleFileUploadUsingArrayAction extends ActionSupport implements UploadedFilesAware {
|
||||
|
||||
private List<UploadedFile> uploadedFiles;
|
||||
|
||||
public List<UploadedFile> getUpload() {
|
||||
return this.uploadedFiles;
|
||||
}
|
||||
|
||||
public String upload() throws Exception {
|
||||
System.out.println("\n\n upload2");
|
||||
System.out.println("files:");
|
||||
|
||||
+5
-1
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.freemarker;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
@@ -34,6 +35,7 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
|
||||
private String[] gender;
|
||||
private String[] months;
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
months = new DateFormatSymbols().getMonths();
|
||||
name = StandardTagsAction.class.getName().substring(StandardTagsAction.class.getName().lastIndexOf(".") + 1);
|
||||
@@ -44,6 +46,7 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
|
||||
return name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -52,15 +55,16 @@ public class StandardTagsAction extends ActionSupport implements Preparable {
|
||||
return months;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setMonths(String[] months) {
|
||||
this.months = months;
|
||||
}
|
||||
|
||||
|
||||
public String[] getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setGender(String[] gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
+4
-2
@@ -21,11 +21,11 @@
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
|
||||
public class GuessCharacterAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 9050915577007590674L;
|
||||
@@ -34,6 +34,7 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
|
||||
private Character character;
|
||||
private Hangman hangman;
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
|
||||
hangman.guess(character);
|
||||
@@ -45,6 +46,7 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
|
||||
return hangman;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setCharacter(Character character) {
|
||||
this.character = character;
|
||||
}
|
||||
|
||||
+5
-1
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.modelDriven;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import org.apache.struts2.showcase.modelDriven.model.Gangster;
|
||||
|
||||
/**
|
||||
* Action to demonstrate simple model-driven feature of the framework.
|
||||
@@ -30,15 +31,18 @@ public class ModelDrivenAction extends ActionSupport implements ModelDriven {
|
||||
|
||||
private static final long serialVersionUID = 1271130427666936592L;
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public Object getModel() {
|
||||
@Override
|
||||
public Gangster getModel() {
|
||||
return new Gangster();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.struts2.showcase.modelDriven;
|
||||
package org.apache.struts2.showcase.modelDriven.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+4
-2
@@ -23,10 +23,10 @@ package org.apache.struts2.showcase.person;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,13 +42,14 @@ public class EditPersonAction extends ActionSupport {
|
||||
|
||||
@Autowired
|
||||
private PersonManager personManager;
|
||||
private List<Person> persons = new ArrayList<Person>();
|
||||
private List<Person> persons = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* A default implementation that does nothing an returns "success".
|
||||
*
|
||||
* @return {@link #INPUT}
|
||||
*/
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
persons.addAll(personManager.getPeople());
|
||||
return INPUT;
|
||||
@@ -68,6 +69,7 @@ public class EditPersonAction extends ActionSupport {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@StrutsParameter(depth = 2)
|
||||
public List<Person> getPersons() {
|
||||
return persons;
|
||||
}
|
||||
|
||||
+2
-1
@@ -35,8 +35,9 @@ public class ListPeopleAction extends ActionSupport {
|
||||
@Autowired
|
||||
private PersonManager personManager;
|
||||
|
||||
private List<Person> people = new ArrayList<Person>();
|
||||
private final List<Person> people = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String execute() {
|
||||
people.addAll(personManager.getPeople());
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ package org.apache.struts2.showcase.person;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@@ -38,12 +39,14 @@ public class NewPersonAction extends ActionSupport {
|
||||
private PersonManager personManager;
|
||||
private Person person;
|
||||
|
||||
@Override
|
||||
public String execute() {
|
||||
personManager.createPerson(person);
|
||||
|
||||
return "list";
|
||||
}
|
||||
|
||||
@StrutsParameter(depth = 1)
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
+9
-3
@@ -23,6 +23,7 @@ package org.apache.struts2.showcase.source;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import org.apache.struts2.action.ServletContextAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import java.io.BufferedReader;
|
||||
@@ -98,8 +99,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
/**
|
||||
* @param className the className to set
|
||||
*/
|
||||
@StrutsParameter
|
||||
public void setClassName(String className) {
|
||||
if (className != null && className.trim().length() > 0) {
|
||||
if (className != null && !className.trim().isEmpty()) {
|
||||
this.className = className;
|
||||
}
|
||||
}
|
||||
@@ -107,8 +109,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
/**
|
||||
* @param config the config to set
|
||||
*/
|
||||
@StrutsParameter
|
||||
public void setConfig(String config) {
|
||||
if (config != null && config.trim().length() > 0) {
|
||||
if (config != null && !config.trim().isEmpty()) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
@@ -116,8 +119,9 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
/**
|
||||
* @param page the page to set
|
||||
*/
|
||||
@StrutsParameter
|
||||
public void setPage(String page) {
|
||||
if (page != null && page.trim().length() > 0) {
|
||||
if (page != null && !page.trim().isEmpty()) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
@@ -125,6 +129,7 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
/**
|
||||
* @param padding the padding to set
|
||||
*/
|
||||
@StrutsParameter
|
||||
public void setPadding(int padding) {
|
||||
this.padding = padding;
|
||||
}
|
||||
@@ -222,6 +227,7 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
return snippet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withServletContext(ServletContext arg0) {
|
||||
this.servletContext = arg0;
|
||||
}
|
||||
|
||||
+3
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.tag.nonui.actionPrefix;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class SubmitAction extends ActionSupport {
|
||||
|
||||
@@ -32,10 +33,12 @@ public class SubmitAction extends ActionSupport {
|
||||
return text;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,8 +23,9 @@ import org.apache.struts2.dispatcher.PrepareOperations;
|
||||
|
||||
public class DebugTagAction extends ActionSupport {
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
PrepareOperations.overrideDevMode(true); // Just for Showcase, explicitly switch on for this action only
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -47,25 +48,25 @@ public class AppendIteratorTagDemo extends ActionSupport implements Validateable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getIteratorValue1() {
|
||||
return iteratorValue1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIteratorValue1(String iteratorValue1) {
|
||||
this.iteratorValue1 = iteratorValue1;
|
||||
}
|
||||
|
||||
|
||||
public String getIteratorValue2() {
|
||||
return iteratorValue2;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIteratorValue2(String iteratorValue2) {
|
||||
this.iteratorValue2 = iteratorValue2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+5
-4
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -37,34 +38,34 @@ public class IteratorGeneratorTagDemo extends ActionSupport {
|
||||
return value;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
public String getSeparator() {
|
||||
return this.separator;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+5
-4
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,7 +34,7 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
|
||||
private String iteratorValue1;
|
||||
private String iteratorValue2;
|
||||
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
if (iteratorValue1 == null || iteratorValue1.trim().length() <= 0) {
|
||||
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
|
||||
@@ -47,25 +48,25 @@ public class MergeIteratorTagDemo extends ActionSupport implements Validateable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getIteratorValue1() {
|
||||
return this.iteratorValue1;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIteratorValue1(String iteratorValue1) {
|
||||
this.iteratorValue1 = iteratorValue1;
|
||||
}
|
||||
|
||||
|
||||
public String getIteratorValue2() {
|
||||
return this.iteratorValue2;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIteratorValue2(String iteratorValue2) {
|
||||
this.iteratorValue2 = iteratorValue2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
+6
-7
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,7 +35,7 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
|
||||
private Integer count;
|
||||
private Integer start;
|
||||
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
if (iteratorValue == null || iteratorValue.trim().length() <= 0) {
|
||||
addFieldError("iteratorValue1", "iterator value 1 cannot be empty");
|
||||
@@ -43,34 +44,34 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getIteratorValue() {
|
||||
return this.iteratorValue;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIteratorValue(String iteratorValue) {
|
||||
this.iteratorValue = iteratorValue;
|
||||
}
|
||||
|
||||
|
||||
public Integer getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
||||
public Integer getStart() {
|
||||
return this.start;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setStart(Integer start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -78,6 +79,4 @@ public class SubsetIteratorTagDemo extends ActionSupport implements Validateable
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package org.apache.struts2.showcase.token;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -76,6 +77,7 @@ public class TokenAction extends ActionSupport {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ public abstract class AbstractValidationActionSupport extends ActionSupport {
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String input() throws Exception {
|
||||
return "input";
|
||||
}
|
||||
|
||||
+20
-11
@@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
|
||||
@@ -29,6 +27,9 @@ import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: ajaxFormSubmit -->
|
||||
@@ -72,9 +73,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@DateRangeFieldValidator(
|
||||
min="01/01/1990",
|
||||
max="01/01/2000",
|
||||
min="01/01/1990",
|
||||
max="01/01/2000",
|
||||
message="must be a min 01-01-1990 max 01-01-2000 if supplied")
|
||||
@StrutsParameter
|
||||
public void setDateValidatorField(Date dateValidatorField) {
|
||||
this.dateValidatorField = dateValidatorField;
|
||||
}
|
||||
@@ -84,6 +86,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@EmailValidator(message="must be a valid email if supplied")
|
||||
@StrutsParameter
|
||||
public void setEmailValidatorField(String emailValidatorField) {
|
||||
this.emailValidatorField = emailValidatorField;
|
||||
}
|
||||
@@ -93,6 +96,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@IntRangeFieldValidator(min="1", max="10", message="must be integer min 1 max 10 if supplied")
|
||||
@StrutsParameter
|
||||
public void setIntegerValidatorField(Integer integerValidatorField) {
|
||||
this.integerValidatorField = integerValidatorField;
|
||||
}
|
||||
@@ -102,8 +106,9 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@RegexFieldValidator(
|
||||
regex="[^<>]+",
|
||||
regex="[^<>]+",
|
||||
message="regexValidatorField must match a regexp (.*\\.txt) if specified")
|
||||
@StrutsParameter
|
||||
public void setRegexValidatorField(String regexValidatorField) {
|
||||
this.regexValidatorField = regexValidatorField;
|
||||
}
|
||||
@@ -113,6 +118,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@RequiredStringValidator(trim=true, message="required and must be string")
|
||||
@StrutsParameter
|
||||
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
|
||||
this.requiredStringValidatorField = requiredStringValidatorField;
|
||||
}
|
||||
@@ -122,6 +128,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@RequiredFieldValidator(message="required")
|
||||
@StrutsParameter
|
||||
public void setRequiredValidatorField(String requiredValidatorField) {
|
||||
this.requiredValidatorField = requiredValidatorField;
|
||||
}
|
||||
@@ -131,10 +138,11 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@StringLengthFieldValidator(
|
||||
minLength="2",
|
||||
maxLength="4",
|
||||
trim=true,
|
||||
minLength="2",
|
||||
maxLength="4",
|
||||
trim=true,
|
||||
message="must be a String of a specific greater than 1 less than 5 if specified")
|
||||
@StrutsParameter
|
||||
public void setStringLengthValidatorField(String stringLengthValidatorField) {
|
||||
this.stringLengthValidatorField = stringLengthValidatorField;
|
||||
}
|
||||
@@ -144,10 +152,10 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@FieldExpressionValidator(
|
||||
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
|
||||
expression = "(fieldExpressionValidatorField == requiredValidatorField)",
|
||||
message = "must be the same as the Required Validator Field if specified")
|
||||
public void setFieldExpressionValidatorField(
|
||||
String fieldExpressionValidatorField) {
|
||||
@StrutsParameter
|
||||
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
|
||||
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
|
||||
}
|
||||
|
||||
@@ -156,6 +164,7 @@ public class AjaxFormSubmitAction extends AbstractValidationActionSupport {
|
||||
}
|
||||
|
||||
@UrlValidator(message="must be a valid url if supplied")
|
||||
@StrutsParameter
|
||||
public void setUrlValidatorField(String urlValidatorField) {
|
||||
this.urlValidatorField = urlValidatorField;
|
||||
}
|
||||
|
||||
+11
-2
@@ -26,6 +26,7 @@ import org.apache.struts2.convention.annotation.Action;
|
||||
import org.apache.struts2.convention.annotation.Namespace;
|
||||
import org.apache.struts2.convention.annotation.ParentPackage;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.interceptor.validation.SkipValidation;
|
||||
import org.hibernate.validator.constraints.ScriptAssert;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
@@ -95,6 +96,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return dateValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setDateValidatorField(Date dateValidatorField) {
|
||||
this.dateValidatorField = dateValidatorField;
|
||||
}
|
||||
@@ -103,6 +105,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return emailValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setEmailValidatorField(String emailValidatorField) {
|
||||
this.emailValidatorField = emailValidatorField;
|
||||
}
|
||||
@@ -111,6 +114,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return integerValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setIntegerValidatorField(Integer integerValidatorField) {
|
||||
this.integerValidatorField = integerValidatorField;
|
||||
}
|
||||
@@ -119,6 +123,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return regexValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRegexValidatorField(String regexValidatorField) {
|
||||
this.regexValidatorField = regexValidatorField;
|
||||
}
|
||||
@@ -127,6 +132,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return requiredStringValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRequiredStringValidatorField(String requiredStringValidatorField) {
|
||||
this.requiredStringValidatorField = requiredStringValidatorField;
|
||||
}
|
||||
@@ -135,6 +141,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return requiredValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setRequiredValidatorField(String requiredValidatorField) {
|
||||
this.requiredValidatorField = requiredValidatorField;
|
||||
}
|
||||
@@ -143,6 +150,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return stringLengthValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setStringLengthValidatorField(String stringLengthValidatorField) {
|
||||
this.stringLengthValidatorField = stringLengthValidatorField;
|
||||
}
|
||||
@@ -151,8 +159,8 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return fieldExpressionValidatorField;
|
||||
}
|
||||
|
||||
public void setFieldExpressionValidatorField(
|
||||
String fieldExpressionValidatorField) {
|
||||
@StrutsParameter
|
||||
public void setFieldExpressionValidatorField(String fieldExpressionValidatorField) {
|
||||
this.fieldExpressionValidatorField = fieldExpressionValidatorField;
|
||||
}
|
||||
|
||||
@@ -160,6 +168,7 @@ public class BeanValidationExampleAction extends ActionSupport {
|
||||
return urlValidatorField;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setUrlValidatorField(String urlValidatorField) {
|
||||
this.urlValidatorField = urlValidatorField;
|
||||
}
|
||||
|
||||
+5
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
@@ -37,6 +39,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
|
||||
return someText;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSomeText(String someText) {
|
||||
this.someText = someText;
|
||||
}
|
||||
@@ -45,6 +48,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
|
||||
return someTextRetype;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSomeTextRetype(String someTextRetype) {
|
||||
this.someTextRetype = someTextRetype;
|
||||
}
|
||||
@@ -53,6 +57,7 @@ public class NonFieldValidatorsExampleAction extends AbstractValidationActionSup
|
||||
return someTextRetypeAgain;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setSomeTextRetypeAgain(String someTextRetypeAgain) {
|
||||
this.someTextRetypeAgain = someTextRetypeAgain;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -39,6 +40,7 @@ public class QuizAction extends ActionSupport {
|
||||
return name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -47,6 +49,7 @@ public class QuizAction extends ActionSupport {
|
||||
return age;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
@@ -55,6 +58,7 @@ public class QuizAction extends ActionSupport {
|
||||
return answer;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer;
|
||||
}
|
||||
|
||||
+3
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
* @version $Date$ $Id$
|
||||
@@ -30,6 +31,7 @@ public class SubmitApplication extends ActionSupport {
|
||||
private String name;
|
||||
private Integer age;
|
||||
|
||||
@StrutsParameter
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -38,6 +40,7 @@ public class SubmitApplication extends ActionSupport {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
+3
@@ -23,12 +23,15 @@ package org.apache.struts2.showcase.validation;
|
||||
|
||||
// START SNIPPET: visitorValidatorsExample
|
||||
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class VisitorValidatorsExampleAction extends AbstractValidationActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 4375454086939598216L;
|
||||
|
||||
private User user;
|
||||
|
||||
@StrutsParameter(depth = 1)
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
package org.apache.struts2.showcase.xslt;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.struts2.action.ServletRequestAware;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
@@ -72,7 +70,7 @@ public class JVMAction implements ServletRequestAware {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public class ImportantInfo {
|
||||
public static class ImportantInfo {
|
||||
private String classpath;
|
||||
private Properties systemProperties;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</action>
|
||||
|
||||
<action name="doMultipleUploadUsingList" class="org.apache.struts2.showcase.fileupload.MultipleFileUploadUsingListAction" method="upload">
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingList.jsp</result>
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingList.jsp</result>
|
||||
<result>/WEB-INF/fileupload/multiple-success.jsp</result>
|
||||
</action>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</action>
|
||||
|
||||
<action name="doMultipleUploadUsingArray" class="org.apache.struts2.showcase.fileupload.MultipleFileUploadUsingArrayAction" method="upload">
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingArray.jsp</result>
|
||||
<result name="input">/WEB-INF/fileupload/multipleUploadUsingArray.jsp</result>
|
||||
<result>/WEB-INF/fileupload/multiple-success.jsp</result>
|
||||
</action>
|
||||
|
||||
|
||||
@@ -36,6 +36,15 @@
|
||||
|
||||
<constant name="struts.allowlist.enable" value="true" />
|
||||
<constant name="struts.parameters.requireAnnotations" value="true" />
|
||||
<constant name="struts.allowlist.packageNames" value="
|
||||
org.apache.struts2.showcase.model,
|
||||
org.apache.struts2.showcase.modelDriven.model
|
||||
"/>
|
||||
<constant name="struts.allowlist.classes" value="
|
||||
org.apache.struts2.showcase.hangman.Hangman,
|
||||
org.apache.struts2.showcase.hangman.HangmanConstants,
|
||||
org.apache.struts2.showcase.hangman.Vocab
|
||||
"/>
|
||||
|
||||
<constant name="struts.convention.package.locators.basePackage" value="org.apache.struts2.showcase" />
|
||||
<constant name="struts.convention.result.path" value="/WEB-INF" />
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
<li>FileName: <s:property value="fileName" /></li>
|
||||
<li>Original FileName: <s:property value="originalName" /></li>
|
||||
<li>File: <s:property value="uploadedFile" /></li>
|
||||
<li>Caption:<s:property value="caption" /></li>
|
||||
<li>Caption: <s:property value="caption" /></li>
|
||||
<li id="input-name">Input name: <s:property value="inputName" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 it.org.apache.struts2.showcase;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConventionTest {
|
||||
|
||||
private WebClient webClient;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
webClient = new WebClient();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
webClient.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listPeople() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/list-people.action");
|
||||
|
||||
assertThat(page.asNormalizedText()).contains(
|
||||
"3\tAlexandru\tPapesco\n" +
|
||||
"4\tJay\tBoss\n" +
|
||||
"5\tRainer\tHermanos\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editPeople() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/edit-person.action");
|
||||
HtmlForm form = page.getForms().get(0);
|
||||
|
||||
form.getInputByName("persons(1).name").setValue("Lukasz");
|
||||
form.getInputByName("persons(1).lastName").setValue("Lenart");
|
||||
form.getInputByName("persons(2).name").setValue("Kusal");
|
||||
form.getInputByName("persons(2).lastName").setValue("Kithul-Godage");
|
||||
|
||||
HtmlSubmitInput button = form.getInputByValue("Save all persons");
|
||||
page = button.click();
|
||||
|
||||
assertThat(page.asNormalizedText()).contains(
|
||||
"1\tLukasz\tLenart\n" +
|
||||
"2\tKusal\tKithul-Godage\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPerson() throws Exception {
|
||||
HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/person/new-person!input.action");
|
||||
HtmlForm form = page.getForms().get(0);
|
||||
|
||||
form.getInputByName("person.name").type("Lukasz");
|
||||
form.getInputByName("person.lastName").type("Lenart");
|
||||
|
||||
HtmlSubmitInput button = form.getInputByValue("Create person");
|
||||
page = button.click();
|
||||
|
||||
assertThat(page.asNormalizedText()).contains("6\tLukasz\tLenart\n");
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,14 @@ import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class FileUploadTest {
|
||||
|
||||
@@ -45,9 +49,31 @@ public class FileUploadTest {
|
||||
uploadInput.setValueAttribute(tempFile.getAbsolutePath());
|
||||
final HtmlSubmitInput button = form.getInputByValue("Submit");
|
||||
final HtmlPage resultPage = button.click();
|
||||
|
||||
DomElement errorMessage = resultPage.getFirstByXPath("//span[@class='errorMessage']");
|
||||
Assert.assertNotNull(errorMessage);
|
||||
Assert.assertEquals("File cannot be empty", errorMessage.getVisibleText());
|
||||
assertNotNull(errorMessage);
|
||||
assertEquals("File cannot be empty", errorMessage.getVisibleText());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileUpload() throws Exception {
|
||||
try (final WebClient webClient = new WebClient()) {
|
||||
final HtmlPage page = webClient.getPage(ParameterUtils.getBaseUrl() + "/fileupload/doUpload.action");
|
||||
final HtmlForm form = page.getFormByName("doUpload");
|
||||
HtmlInput captionInput = form.getInputByName("caption");
|
||||
HtmlFileInput uploadInput = form.getInputByName("upload");
|
||||
captionInput.type("some caption");
|
||||
File tempFile = File.createTempFile("testEmptyFile", ".tmp");
|
||||
Files.write(Paths.get(tempFile.toURI()), "some content".getBytes());
|
||||
tempFile.deleteOnExit();
|
||||
uploadInput.setValueAttribute(tempFile.getAbsolutePath());
|
||||
final HtmlSubmitInput button = form.getInputByValue("Submit");
|
||||
final HtmlPage resultPage = button.click();
|
||||
|
||||
DomElement inputName = resultPage.getElementById("input-name");
|
||||
assertNotNull(inputName);
|
||||
assertEquals("Input name: upload", inputName.getTextContent().trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-assembly</artifactId>
|
||||
|
||||
+4
-4
@@ -25,11 +25,11 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-bom</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Struts 2 Bill of Materials</name>
|
||||
@@ -44,7 +44,7 @@
|
||||
</licenses>
|
||||
|
||||
<properties>
|
||||
<struts-version.version>6.5.0</struts-version.version>
|
||||
<struts-version.version>6.7.4</struts-version.version>
|
||||
<maven.site.skip>true</maven.site.skip>
|
||||
<maven.site.deploy.skip>true</maven.site.deploy.skip>
|
||||
</properties>
|
||||
@@ -190,7 +190,7 @@
|
||||
</dependencyManagement>
|
||||
|
||||
<scm>
|
||||
<tag>STRUTS_6_5_0</tag>
|
||||
<tag>STRUTS_6_7_4</tag>
|
||||
<connection>scm:git:https://gitbox.apache.org/repos/asf/struts.git</connection>
|
||||
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/struts.git</developerConnection>
|
||||
<url>https://github.com/apache/struts/</url>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-admin-bundle</artifactId>
|
||||
|
||||
+6
-5
@@ -25,10 +25,11 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.struts2.osgi.BundleAccessor;
|
||||
import org.apache.struts2.osgi.host.OsgiHost;
|
||||
import org.apache.struts2.osgi.StrutsOsgiListener;
|
||||
import org.apache.struts2.action.ServletContextAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.osgi.BundleAccessor;
|
||||
import org.apache.struts2.osgi.StrutsOsgiListener;
|
||||
import org.apache.struts2.osgi.host.OsgiHost;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleException;
|
||||
|
||||
@@ -36,9 +37,8 @@ import javax.servlet.ServletContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class BundlesAction extends ActionSupport implements ServletContextAware {
|
||||
|
||||
@@ -114,6 +114,7 @@ public class BundlesAction extends ActionSupport implements ServletContextAware
|
||||
return id;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -21,25 +21,25 @@
|
||||
|
||||
package org.apache.struts2.osgi.admin.actions;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.felix.shell.ShellService;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.osgi.DefaultBundleAccessor;
|
||||
import org.apache.struts2.osgi.interceptor.BundleContextAware;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* This action executes commands on the Felix Shell.
|
||||
*
|
||||
*
|
||||
* The action is BundleContextAware so that if the OSGi interceptor is used the BundleContext
|
||||
* can be provided for configurations where the DefaultBundleAccessor is insufficient.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ShellAction extends ActionSupport implements BundleContextAware {
|
||||
private String command;
|
||||
@@ -77,6 +77,7 @@ public class ShellAction extends ActionSupport implements BundleContextAware {
|
||||
return command;
|
||||
}
|
||||
|
||||
@StrutsParameter
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-demo-bundle</artifactId>
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.osgi.framework.BundleContext;
|
||||
public class BundlesAction extends ActionSupport implements BundleContextAware {
|
||||
private BundleContext bundleContext;
|
||||
|
||||
@Override
|
||||
public void withBundleContext(BundleContext bundleContext) {
|
||||
this.bundleContext = bundleContext;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.apache.struts2.convention.annotation.Actions;
|
||||
import org.apache.struts2.convention.annotation.Namespace;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.ResultPath;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
@Namespace("/osgi")
|
||||
@ResultPath("/content/osgi")
|
||||
@@ -41,6 +42,7 @@ public class HelloWorldAction extends ActionSupport {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@StrutsParameter(depth = 1)
|
||||
public Message getMessage() {
|
||||
return message;
|
||||
}
|
||||
@@ -60,4 +62,4 @@ public class HelloWorldAction extends ActionSupport {
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-osgi-bundles</artifactId>
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>6.5.0</version>
|
||||
<version>6.7.4</version>
|
||||
</parent>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -19,70 +19,10 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
/**
|
||||
* All actions <b>may</b> implement this interface, which exposes the <code>execute()</code> method.
|
||||
* <p>
|
||||
* However, as of XWork 1.1, this is <b>not</b> required and is only here to assist users. You are free to create POJOs
|
||||
* that honor the same contract defined by this interface without actually implementing the interface.
|
||||
* </p>
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.action.Action} instead.
|
||||
*/
|
||||
public interface Action {
|
||||
|
||||
/**
|
||||
* The action execution was successful. Show result
|
||||
* view to the end user.
|
||||
*/
|
||||
public static final String SUCCESS = "success";
|
||||
|
||||
/**
|
||||
* The action execution was successful but do not
|
||||
* show a view. This is useful for actions that are
|
||||
* handling the view in another fashion like redirect.
|
||||
*/
|
||||
public static final String NONE = "none";
|
||||
|
||||
/**
|
||||
* The action execution was a failure.
|
||||
* Show an error view, possibly asking the
|
||||
* user to retry entering data.
|
||||
*/
|
||||
public static final String ERROR = "error";
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The action execution require more input
|
||||
* in order to succeed.
|
||||
* This result is typically used if a form
|
||||
* handling action has been executed so as
|
||||
* to provide defaults for a form. The
|
||||
* form associated with the handler should be
|
||||
* shown to the end user.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This result is also used if the given input
|
||||
* params are invalid, meaning the user
|
||||
* should try providing input again.
|
||||
* </p>
|
||||
*/
|
||||
public static final String INPUT = "input";
|
||||
|
||||
/**
|
||||
* The action could not execute, since the
|
||||
* user most was not logged in. The login view
|
||||
* should be shown.
|
||||
*/
|
||||
public static final String LOGIN = "login";
|
||||
|
||||
|
||||
/**
|
||||
* Where the logic of the action is executed.
|
||||
*
|
||||
* @return a string representing the logical result of the execution.
|
||||
* See constants in this interface for a list of standard result values.
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
* <b>Note:</b> Application level exceptions should be handled by returning
|
||||
* an error value, such as <code>Action.ERROR</code>.
|
||||
*/
|
||||
public String execute() throws Exception;
|
||||
|
||||
@Deprecated
|
||||
public interface Action extends org.apache.struts2.action.Action {
|
||||
}
|
||||
|
||||
@@ -18,263 +18,21 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.TextParseUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
* This result invokes an entire other action, complete with it's own interceptor stack and result.
|
||||
*
|
||||
* <!-- END SNIPPET: description -->
|
||||
*
|
||||
* <b>This result type takes the following parameters:</b>
|
||||
*
|
||||
* <!-- START SNIPPET: params -->
|
||||
*
|
||||
* <ul>
|
||||
*
|
||||
* <li><b>actionName (default)</b> - the name of the action that will be chained to</li>
|
||||
*
|
||||
* <li><b>namespace</b> - used to determine which namespace the Action is in that we're chaining. If namespace is null,
|
||||
* this defaults to the current namespace</li>
|
||||
*
|
||||
* <li><b>method</b> - used to specify another method on target action to be invoked.
|
||||
* If null, this defaults to execute method</li>
|
||||
*
|
||||
* <li><b>skipActions</b> - (optional) the list of comma separated action names for the
|
||||
* actions that could be chained to</li>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* <!-- END SNIPPET: params -->
|
||||
*
|
||||
* <b>Example:</b>
|
||||
*
|
||||
* <pre><!-- START SNIPPET: example -->
|
||||
* <package name="public" extends="struts-default">
|
||||
* <!-- Chain creatAccount to login, using the default parameter -->
|
||||
* <action name="createAccount" class="...">
|
||||
* <result type="chain">login</result>
|
||||
* </action>
|
||||
*
|
||||
* <action name="login" class="...">
|
||||
* <!-- Chain to another namespace -->
|
||||
* <result type="chain">
|
||||
* <param name="actionName">dashboard</param>
|
||||
* <param name="namespace">/secure</param>
|
||||
* </result>
|
||||
* </action>
|
||||
* </package>
|
||||
*
|
||||
* <package name="secure" extends="struts-default" namespace="/secure">
|
||||
* <action name="dashboard" class="...">
|
||||
* <result>dashboard.jsp</result>
|
||||
* </action>
|
||||
* </package>
|
||||
* <!-- END SNIPPET: example --></pre>
|
||||
*
|
||||
* @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
|
||||
*/
|
||||
public class ActionChainResult implements Result {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ActionChainResult.class);
|
||||
|
||||
/**
|
||||
* The result parameter name to set the name of the action to chain to.
|
||||
*/
|
||||
public static final String DEFAULT_PARAM = "actionName";
|
||||
|
||||
/**
|
||||
* The action context key to save the chain history.
|
||||
*/
|
||||
private static final String CHAIN_HISTORY = "CHAIN_HISTORY";
|
||||
|
||||
private ActionProxy proxy;
|
||||
private String actionName;
|
||||
|
||||
private String namespace;
|
||||
|
||||
private String methodName;
|
||||
|
||||
/**
|
||||
* The list of actions to skip.
|
||||
*/
|
||||
private String skipActions;
|
||||
|
||||
private ActionProxyFactory actionProxyFactory;
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.result.ActionChainResult} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ActionChainResult extends org.apache.struts2.result.ActionChainResult {
|
||||
|
||||
public ActionChainResult() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ActionChainResult(String namespace, String actionName, String methodName) {
|
||||
this.namespace = namespace;
|
||||
this.actionName = actionName;
|
||||
this.methodName = methodName;
|
||||
super(namespace, actionName, methodName);
|
||||
}
|
||||
|
||||
public ActionChainResult(String namespace, String actionName, String methodName, String skipActions) {
|
||||
this.namespace = namespace;
|
||||
this.actionName = actionName;
|
||||
this.methodName = methodName;
|
||||
this.skipActions = skipActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actionProxyFactory the actionProxyFactory to set
|
||||
*/
|
||||
@Inject
|
||||
public void setActionProxyFactory(ActionProxyFactory actionProxyFactory) {
|
||||
this.actionProxyFactory = actionProxyFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the action name.
|
||||
*
|
||||
* @param actionName The action name.
|
||||
*/
|
||||
public void setActionName(String actionName) {
|
||||
this.actionName = actionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the namespace of the Action that we're chaining to. if namespace
|
||||
* is null, this defaults to the current namespace.
|
||||
*
|
||||
* @param namespace the name of the namespace we're chaining to
|
||||
*/
|
||||
public void setNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of actions to skip.
|
||||
* To test if an action should not throe an infinite recursion,
|
||||
* only the action name is used, not the namespace.
|
||||
*
|
||||
* @param actions The list of action name separated by a white space.
|
||||
*/
|
||||
public void setSkipActions(String actions) {
|
||||
this.skipActions = actions;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.methodName = method;
|
||||
}
|
||||
|
||||
public ActionProxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the XWork chain history.
|
||||
* The stack is a list of <code>namespace/action!method</code> keys.
|
||||
*
|
||||
* @return the chain history as string list
|
||||
*/
|
||||
public static LinkedList<String> getChainHistory() {
|
||||
LinkedList<String> chainHistory = (LinkedList<String>) ActionContext.getContext().get(CHAIN_HISTORY);
|
||||
// Add if not exists
|
||||
if (chainHistory == null) {
|
||||
chainHistory = new LinkedList<>();
|
||||
ActionContext.getContext().put(CHAIN_HISTORY, chainHistory);
|
||||
}
|
||||
|
||||
return chainHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param invocation the DefaultActionInvocation calling the action call stack
|
||||
*/
|
||||
public void execute(ActionInvocation invocation) throws Exception {
|
||||
if (invocation == null) {
|
||||
throw new IllegalArgumentException("Invocation cannot be null!");
|
||||
}
|
||||
|
||||
String finalNamespace = namespace != null ? translateVariables(namespace) : invocation.getProxy()
|
||||
.getNamespace();
|
||||
String finalActionName = translateVariables(actionName);
|
||||
String finalMethodName = methodName != null ? translateVariables(methodName) : null;
|
||||
|
||||
if (isInChainHistory(finalNamespace, finalActionName, finalMethodName)) {
|
||||
addToHistory(finalNamespace, finalActionName, finalMethodName);
|
||||
throw new StrutsException("Infinite recursion detected: " + ActionChainResult.getChainHistory());
|
||||
}
|
||||
|
||||
if (ActionChainResult.getChainHistory().isEmpty() && invocation.getProxy() != null) {
|
||||
addToHistory(finalNamespace, invocation.getProxy().getActionName(), invocation.getProxy().getMethod());
|
||||
}
|
||||
addToHistory(finalNamespace, finalActionName, finalMethodName);
|
||||
|
||||
Map<String, Object> extraContext = ActionContext.of()
|
||||
.withValueStack(invocation.getInvocationContext().getValueStack())
|
||||
.withParameters(invocation.getInvocationContext().getParameters())
|
||||
.with(CHAIN_HISTORY, ActionChainResult.getChainHistory())
|
||||
.getContextMap();
|
||||
|
||||
LOG.debug("Chaining to action {}", finalActionName);
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy(finalNamespace, finalActionName, finalMethodName, extraContext);
|
||||
proxy.execute();
|
||||
}
|
||||
|
||||
protected String translateVariables(String text) {
|
||||
return TextParseUtil.translateVariables(text, ActionContext.getContext().getValueStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ActionChainResult that = (ActionChainResult) o;
|
||||
return Objects.equals(actionName, that.actionName) && Objects.equals(methodName,
|
||||
that.methodName) && Objects.equals(namespace, that.namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = (actionName != null ? actionName.hashCode() : 0);
|
||||
result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
|
||||
result = 31 * result + (methodName != null ? methodName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isInChainHistory(String namespace, String actionName, String methodName) {
|
||||
LinkedList<? extends String> chainHistory = ActionChainResult.getChainHistory();
|
||||
Set<String> skipActionsList = new HashSet<>();
|
||||
if (skipActions != null && skipActions.length() > 0) {
|
||||
String finalSkipActions = translateVariables(skipActions);
|
||||
skipActionsList.addAll(TextParseUtil.commaDelimitedStringToSet(finalSkipActions));
|
||||
}
|
||||
if (!skipActionsList.contains(actionName)) {
|
||||
return chainHistory.contains(makeKey(namespace, actionName, methodName));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void addToHistory(String namespace, String actionName, String methodName) {
|
||||
List<String> chainHistory = ActionChainResult.getChainHistory();
|
||||
chainHistory.add(makeKey(namespace, actionName, methodName));
|
||||
}
|
||||
|
||||
private String makeKey(String namespace, String actionName, String methodName) {
|
||||
return namespace + "/" + actionName + (methodName != null ? "!" + methodName : "");
|
||||
super(namespace, actionName, methodName, skipActions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ package com.opensymphony.xwork2;
|
||||
import com.opensymphony.xwork2.conversion.impl.ConversionData;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.StrutsStatics;
|
||||
import org.apache.struts2.dispatcher.HttpParameters;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
@@ -30,515 +28,249 @@ import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The ActionContext is the context in which an {@link Action} is executed. Each context is basically a
|
||||
* container of objects an action needs for execution like the session, parameters, locale, etc.
|
||||
* </p>
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>
|
||||
* The ActionContext is thread local which means that values stored in the ActionContext are
|
||||
* unique per thread. See the {@link ThreadLocal} class for more information. The benefit of
|
||||
* this is you don't need to worry about a user specific action context, you just get it:
|
||||
* </p>
|
||||
*
|
||||
* <code>ActionContext context = ActionContext.getContext();</code>
|
||||
*
|
||||
* <p>
|
||||
* Finally, because of the thread local usage you don't need to worry about making your actions thread safe.
|
||||
* </p>
|
||||
*
|
||||
* @author Patrick Lightbody
|
||||
* @author Bill Lynch (docs)
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionContext} instead.
|
||||
*/
|
||||
public class ActionContext implements Serializable {
|
||||
@Deprecated
|
||||
public class ActionContext extends org.apache.struts2.ActionContext {
|
||||
|
||||
private static final ThreadLocal<ActionContext> actionContext = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Constant for the name of the action being executed.
|
||||
*/
|
||||
private static final String ACTION_NAME = "org.apache.struts2.ActionContext.name";
|
||||
|
||||
/**
|
||||
* Constant for the {@link com.opensymphony.xwork2.util.ValueStack OGNL value stack}.
|
||||
*/
|
||||
private static final String VALUE_STACK = ValueStack.VALUE_STACK;
|
||||
|
||||
/**
|
||||
* Constant for the action's session.
|
||||
*/
|
||||
private static final String SESSION = "org.apache.struts2.ActionContext.session";
|
||||
|
||||
/**
|
||||
* Constant for the action's application context.
|
||||
*/
|
||||
private static final String APPLICATION = "org.apache.struts2.ActionContext.application";
|
||||
|
||||
/**
|
||||
* Constant for the action's parameters.
|
||||
*/
|
||||
private static final String PARAMETERS = "org.apache.struts2.ActionContext.parameters";
|
||||
|
||||
/**
|
||||
* Constant for the action's locale.
|
||||
*/
|
||||
private static final String LOCALE = "org.apache.struts2.ActionContext.locale";
|
||||
|
||||
/**
|
||||
* Constant for the action's {@link com.opensymphony.xwork2.ActionInvocation invocation} context.
|
||||
*/
|
||||
private static final String ACTION_INVOCATION = "org.apache.struts2.ActionContext.actionInvocation";
|
||||
|
||||
/**
|
||||
* Constant for the map of type conversion errors.
|
||||
*/
|
||||
private static final String CONVERSION_ERRORS = "org.apache.struts2.ActionContext.conversionErrors";
|
||||
|
||||
/**
|
||||
* Constant for the container
|
||||
*/
|
||||
private static final String CONTAINER = "org.apache.struts2.ActionContext.container";
|
||||
|
||||
private final Map<String, Object> context;
|
||||
|
||||
/**
|
||||
* Creates a new ActionContext initialized with another context.
|
||||
*
|
||||
* @param context a context map.
|
||||
*/
|
||||
protected ActionContext(Map<String, Object> context) {
|
||||
this.context = context;
|
||||
private ActionContext(org.apache.struts2.ActionContext actualContext) {
|
||||
super(actualContext.getContextMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ActionContext based on passed in Map
|
||||
*
|
||||
* @param context a map with context values
|
||||
* @return new ActionContext
|
||||
*/
|
||||
public static ActionContext of(Map<String, Object> context) {
|
||||
if (context == null) {
|
||||
throw new IllegalArgumentException("Context cannot be null!");
|
||||
public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
|
||||
if (actualContext instanceof ActionContext) {
|
||||
return (ActionContext) actualContext;
|
||||
}
|
||||
return new ActionContext(context);
|
||||
return actualContext != null ? new ActionContext(actualContext) : null;
|
||||
}
|
||||
|
||||
public static ActionContext of(Map<String, Object> context) {
|
||||
return adapt(org.apache.struts2.ActionContext.of(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ActionContext based on empty Map
|
||||
*
|
||||
* @return new ActionContext
|
||||
*/
|
||||
public static ActionContext of() {
|
||||
return of(new HashMap<>());
|
||||
return adapt(org.apache.struts2.ActionContext.of());
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the provided context with the current thread
|
||||
*
|
||||
* @param actionContext context to bind to the thread
|
||||
* @return context which was bound to the thread
|
||||
*/
|
||||
public static ActionContext bind(ActionContext actionContext) {
|
||||
ActionContext.setContext(actionContext);
|
||||
return ActionContext.getContext();
|
||||
return adapt(org.apache.struts2.ActionContext.bind(actionContext));
|
||||
}
|
||||
|
||||
public static boolean containsValueStack(Map<String, Object> context) {
|
||||
return context != null && context.containsKey(VALUE_STACK);
|
||||
return org.apache.struts2.ActionContext.containsValueStack(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds this context with the current thread
|
||||
*
|
||||
* @return this context which was bound to the thread
|
||||
*/
|
||||
public ActionContext bind() {
|
||||
ActionContext.setContext(this);
|
||||
return ActionContext.getContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Wipes out current ActionContext, use wisely!
|
||||
*/
|
||||
public static void clear() {
|
||||
actionContext.remove();
|
||||
org.apache.struts2.ActionContext.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action context for the current thread.
|
||||
*
|
||||
* @param context the action context.
|
||||
*/
|
||||
private static void setContext(ActionContext context) {
|
||||
actionContext.set(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActionContext specific to the current thread.
|
||||
*
|
||||
* @return the ActionContext for the current thread, is never <tt>null</tt>.
|
||||
*/
|
||||
public static ActionContext getContext() {
|
||||
return actionContext.get();
|
||||
return adapt(org.apache.struts2.ActionContext.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext bind() {
|
||||
super.bind();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action invocation (the execution state).
|
||||
*
|
||||
* @param actionInvocation the action execution state.
|
||||
*/
|
||||
public ActionContext withActionInvocation(ActionInvocation actionInvocation) {
|
||||
put(ACTION_INVOCATION, actionInvocation);
|
||||
return withActionInvocation((org.apache.struts2.ActionInvocation) actionInvocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext withActionInvocation(org.apache.struts2.ActionInvocation actionInvocation) {
|
||||
super.withActionInvocation(actionInvocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the action invocation (the execution state).
|
||||
*
|
||||
* @return the action invocation (the execution state).
|
||||
*/
|
||||
@Override
|
||||
public ActionInvocation getActionInvocation() {
|
||||
return (ActionInvocation) get(ACTION_INVOCATION);
|
||||
return ActionInvocation.adapt(super.getActionInvocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action's application context.
|
||||
*
|
||||
* @param application the action's application context.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withApplication(Map<String, Object> application) {
|
||||
put(APPLICATION, application);
|
||||
super.withApplication(application);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.
|
||||
*
|
||||
* @return a Map of ServletContext or generic application level Map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> getApplication() {
|
||||
return (Map<String, Object>) get(APPLICATION);
|
||||
return super.getApplication();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the context map.
|
||||
*
|
||||
* @return the context map.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getContextMap() {
|
||||
return context;
|
||||
return super.getContextMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets conversion errors which occurred when executing the action.
|
||||
*
|
||||
* @param conversionErrors a Map of errors which occurred when executing the action.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withConversionErrors(Map<String, ConversionData> conversionErrors) {
|
||||
put(CONVERSION_ERRORS, conversionErrors);
|
||||
super.withConversionErrors(conversionErrors);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the map of conversion errors which occurred when executing the action.
|
||||
*
|
||||
* @return the map of conversion errors which occurred when executing the action or an empty map if
|
||||
* there were no errors.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, ConversionData> getConversionErrors() {
|
||||
Map<String, ConversionData> errors = (Map<String, ConversionData>) get(CONVERSION_ERRORS);
|
||||
|
||||
if (errors == null) {
|
||||
errors = withConversionErrors(new HashMap<>()).getConversionErrors();
|
||||
}
|
||||
|
||||
return errors;
|
||||
return super.getConversionErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Locale for the current action.
|
||||
*
|
||||
* @param locale the Locale for the current action.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withLocale(Locale locale) {
|
||||
put(LOCALE, locale);
|
||||
super.withLocale(locale);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Locale of the current action. If no locale was ever specified the platform's
|
||||
* {@link java.util.Locale#getDefault() default locale} is used.
|
||||
*
|
||||
* @return the Locale of the current action.
|
||||
*/
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
Locale locale = (Locale) get(LOCALE);
|
||||
|
||||
if (locale == null) {
|
||||
locale = Locale.getDefault();
|
||||
withLocale(locale);
|
||||
}
|
||||
|
||||
return locale;
|
||||
return super.getLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the current Action in the ActionContext.
|
||||
*
|
||||
* @param actionName the name of the current action.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withActionName(String actionName) {
|
||||
put(ACTION_NAME, actionName);
|
||||
super.withActionName(actionName);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the current Action.
|
||||
*
|
||||
* @return the name of the current action.
|
||||
*/
|
||||
@Override
|
||||
public String getActionName() {
|
||||
return (String) get(ACTION_NAME);
|
||||
return super.getActionName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action parameters.
|
||||
*
|
||||
* @param parameters the parameters for the current action.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withParameters(HttpParameters parameters) {
|
||||
put(PARAMETERS, parameters);
|
||||
super.withParameters(parameters);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of
|
||||
* parameters otherwise.
|
||||
*
|
||||
* @return a Map of HttpServletRequest parameters or a multipart map when in a servlet environment, or a
|
||||
* generic Map of parameters otherwise.
|
||||
*/
|
||||
@Override
|
||||
public HttpParameters getParameters() {
|
||||
return (HttpParameters) get(PARAMETERS);
|
||||
return super.getParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a map of action session values.
|
||||
*
|
||||
* @param session the session values.
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withSession(Map<String, Object> session) {
|
||||
put(SESSION, session);
|
||||
super.withSession(session);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
|
||||
*
|
||||
* @return the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, Object> getSession() {
|
||||
return (Map<String, Object>) get(SESSION);
|
||||
return super.getSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the OGNL value stack.
|
||||
*
|
||||
* @param valueStack the OGNL value stack.
|
||||
*/
|
||||
public ActionContext withValueStack(ValueStack valueStack) {
|
||||
put(VALUE_STACK, valueStack);
|
||||
return withValueStack((org.apache.struts2.util.ValueStack) valueStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext withValueStack(org.apache.struts2.util.ValueStack valueStack) {
|
||||
super.withValueStack(valueStack);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the OGNL value stack.
|
||||
*
|
||||
* @return the OGNL value stack.
|
||||
*/
|
||||
@Override
|
||||
public ValueStack getValueStack() {
|
||||
return (ValueStack) get(VALUE_STACK);
|
||||
return ValueStack.adapt(super.getValueStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the container for this request
|
||||
*
|
||||
* @param container The container
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withContainer(Container container) {
|
||||
put(CONTAINER, container);
|
||||
super.withContainer(container);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the container for this request
|
||||
*
|
||||
* @return The container
|
||||
*/
|
||||
@Override
|
||||
public Container getContainer() {
|
||||
return (Container) get(CONTAINER);
|
||||
return super.getContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInstance(Class<T> type) {
|
||||
Container cont = getContainer();
|
||||
if (cont != null) {
|
||||
return cont.getInstance(type);
|
||||
} else {
|
||||
throw new StrutsException("Cannot find an initialized container for this request.");
|
||||
}
|
||||
return super.getInstance(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value that is stored in the current ActionContext by doing a lookup using the value's key.
|
||||
*
|
||||
* @param key the key used to find the value.
|
||||
* @return the value that was found using the key or <tt>null</tt> if the key was not found.
|
||||
*/
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
return context.get(key);
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a value in the current ActionContext. The value can be looked up using the key.
|
||||
*
|
||||
* @param key the key of the value.
|
||||
* @param value the value to be stored.
|
||||
*/
|
||||
@Override
|
||||
public void put(String key, Object value) {
|
||||
context.put(key, value);
|
||||
super.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ServletContext associated with current action
|
||||
*
|
||||
* @return current ServletContext
|
||||
*/
|
||||
@Override
|
||||
public ServletContext getServletContext() {
|
||||
return (ServletContext) get(StrutsStatics.SERVLET_CONTEXT);
|
||||
return super.getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns ServletContext to action context
|
||||
*
|
||||
* @param servletContext associated with current request
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withServletContext(ServletContext servletContext) {
|
||||
put(StrutsStatics.SERVLET_CONTEXT, servletContext);
|
||||
super.withServletContext(servletContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ServletRequest associated with current action
|
||||
*
|
||||
* @return current ServletRequest
|
||||
*/
|
||||
@Override
|
||||
public HttpServletRequest getServletRequest() {
|
||||
return (HttpServletRequest) get(StrutsStatics.HTTP_REQUEST);
|
||||
return super.getServletRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns ServletRequest to action context
|
||||
*
|
||||
* @param request associated with current request
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withServletRequest(HttpServletRequest request) {
|
||||
put(StrutsStatics.HTTP_REQUEST, request);
|
||||
super.withServletRequest(request);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ServletResponse associated with current action
|
||||
*
|
||||
* @return current ServletResponse
|
||||
*/
|
||||
@Override
|
||||
public HttpServletResponse getServletResponse() {
|
||||
return (HttpServletResponse) get(StrutsStatics.HTTP_RESPONSE);
|
||||
return super.getServletResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns ServletResponse to action context
|
||||
*
|
||||
* @param response associated with current request
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withServletResponse(HttpServletResponse response) {
|
||||
put(StrutsStatics.HTTP_RESPONSE, response);
|
||||
super.withServletResponse(response);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets PageContext associated with current action
|
||||
*
|
||||
* @return current PageContext
|
||||
*/
|
||||
@Override
|
||||
public PageContext getPageContext() {
|
||||
return (PageContext) get(StrutsStatics.PAGE_CONTEXT);
|
||||
return super.getPageContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns PageContext to action context
|
||||
*
|
||||
* @param pageContext associated with current request
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withPageContext(PageContext pageContext) {
|
||||
put(StrutsStatics.PAGE_CONTEXT, pageContext);
|
||||
super.withPageContext(pageContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ActionMapping associated with current action
|
||||
*
|
||||
* @return current ActionMapping
|
||||
*/
|
||||
@Override
|
||||
public ActionMapping getActionMapping() {
|
||||
return (ActionMapping) get(StrutsStatics.ACTION_MAPPING);
|
||||
return super.getActionMapping();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns ActionMapping to action context
|
||||
*
|
||||
* @param actionMapping associated with current request
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withActionMapping(ActionMapping actionMapping) {
|
||||
put(StrutsStatics.ACTION_MAPPING, actionMapping);
|
||||
super.withActionMapping(actionMapping);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns an extra context map to action context
|
||||
*
|
||||
* @param extraContext to add to the current action context
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext withExtraContext(Map<String, Object> extraContext) {
|
||||
if (extraContext != null) {
|
||||
context.putAll(extraContext);
|
||||
}
|
||||
super.withExtraContext(extraContext);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds arbitrary key to action context
|
||||
*
|
||||
* @param key a string
|
||||
* @param value an object
|
||||
* @return ActionContext
|
||||
*/
|
||||
@Override
|
||||
public ActionContext with(String key, Object value) {
|
||||
put(key, value);
|
||||
super.with(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,24 +21,50 @@ package com.opensymphony.xwork2;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* Provides hooks for handling key action events
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionEventListener} instead.
|
||||
*/
|
||||
public interface ActionEventListener {
|
||||
/**
|
||||
* Called after an action has been created.
|
||||
*
|
||||
* @param action The action
|
||||
* @param stack The current value stack
|
||||
* @return The action to use
|
||||
*/
|
||||
public Object prepare(Object action, ValueStack stack);
|
||||
|
||||
/**
|
||||
* Called when an exception is thrown by the action
|
||||
*
|
||||
* @param t The exception/error that was thrown
|
||||
* @param stack The current value stack
|
||||
* @return A result code to execute, can be null
|
||||
*/
|
||||
public String handleException(Throwable t, ValueStack stack);
|
||||
@Deprecated
|
||||
public interface ActionEventListener extends org.apache.struts2.ActionEventListener {
|
||||
|
||||
@Override
|
||||
default Object prepare(Object action, org.apache.struts2.util.ValueStack stack) {
|
||||
return prepare(action, ValueStack.adapt(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
default String handleException(Throwable t, org.apache.struts2.util.ValueStack stack) {
|
||||
return handleException(t, ValueStack.adapt(stack));
|
||||
}
|
||||
|
||||
Object prepare(Object action, ValueStack stack);
|
||||
|
||||
String handleException(Throwable t, ValueStack stack);
|
||||
|
||||
static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) {
|
||||
if (actualListener instanceof ActionEventListener) {
|
||||
return (ActionEventListener) actualListener;
|
||||
}
|
||||
return actualListener != null ? new LegacyAdapter(actualListener) : null;
|
||||
}
|
||||
|
||||
class LegacyAdapter implements ActionEventListener {
|
||||
|
||||
private final org.apache.struts2.ActionEventListener adaptee;
|
||||
|
||||
private LegacyAdapter(org.apache.struts2.ActionEventListener adaptee) {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object prepare(Object action, ValueStack stack) {
|
||||
return adaptee.prepare(action, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handleException(Throwable t, ValueStack stack) {
|
||||
return adaptee.handleException(t, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,158 +22,125 @@ import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* An {@link ActionInvocation} represents the execution state of an {@link Action}. It holds the Interceptors and the Action instance.
|
||||
* By repeated re-entrant execution of the <code>invoke()</code> method, initially by the {@link ActionProxy}, then by the Interceptors, the
|
||||
* Interceptors are all executed, and then the {@link Action} and the {@link Result}.
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @author Jason Carreira
|
||||
* @see com.opensymphony.xwork2.ActionProxy
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionInvocation} instead.
|
||||
*/
|
||||
public interface ActionInvocation {
|
||||
@Deprecated
|
||||
public interface ActionInvocation extends org.apache.struts2.ActionInvocation {
|
||||
|
||||
/**
|
||||
* Get the Action associated with this ActionInvocation.
|
||||
*
|
||||
* @return the Action
|
||||
*/
|
||||
Object getAction();
|
||||
|
||||
/**
|
||||
* Gets whether this ActionInvocation has executed before.
|
||||
* This will be set after the Action and the Result have executed.
|
||||
*
|
||||
* @return <tt>true</tt> if this ActionInvocation has executed before.
|
||||
*/
|
||||
boolean isExecuted();
|
||||
|
||||
/**
|
||||
* Gets the ActionContext associated with this ActionInvocation. The ActionProxy is
|
||||
* responsible for setting this ActionContext onto the ThreadLocal before invoking
|
||||
* the ActionInvocation and resetting the old ActionContext afterwards.
|
||||
*
|
||||
* @return the ActionContext.
|
||||
*/
|
||||
@Override
|
||||
ActionContext getInvocationContext();
|
||||
|
||||
/**
|
||||
* Get the ActionProxy holding this ActionInvocation.
|
||||
*
|
||||
* @return the ActionProxy.
|
||||
*/
|
||||
ActionProxy getProxy();
|
||||
|
||||
/**
|
||||
* If the ActionInvocation has been executed before and the Result is an instance of {@link ActionChainResult}, this method
|
||||
* will walk down the chain of <code>ActionChainResult</code>s until it finds a non-chain result, which will be returned. If the
|
||||
* ActionInvocation's result has not been executed before, the Result instance will be created and populated with
|
||||
* the result params.
|
||||
*
|
||||
* @return the result.
|
||||
* @throws Exception can be thrown.
|
||||
*/
|
||||
@Override
|
||||
Result getResult() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the result code returned from this ActionInvocation.
|
||||
*
|
||||
* @return the result code
|
||||
*/
|
||||
String getResultCode();
|
||||
@Override
|
||||
ActionProxy getProxy();
|
||||
|
||||
/**
|
||||
* Sets the result code, possibly overriding the one returned by the
|
||||
* action.
|
||||
*
|
||||
* <p>
|
||||
* The "intended" purpose of this method is to allow PreResultListeners to
|
||||
* override the result code returned by the Action.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If this method is used before the Action executes, the Action's returned
|
||||
* result code will override what was set. However the Action could (if
|
||||
* specifically coded to do so) inspect the ActionInvocation to see that
|
||||
* someone "upstream" (e.g. an Interceptor) had suggested a value as the
|
||||
* result, and it could therefore return the same value itself.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If this method is called between the Action execution and the Result
|
||||
* execution, then the value set here will override the result code the
|
||||
* action had returned. Creating an Interceptor that implements
|
||||
* {@link PreResultListener} will give you this opportunity.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If this method is called after the Result has been executed, it will
|
||||
* have the effect of raising an IllegalStateException.
|
||||
* </p>
|
||||
*
|
||||
* @param resultCode the result code.
|
||||
* @throws IllegalStateException if called after the Result has been executed.
|
||||
* @see #isExecuted()
|
||||
*/
|
||||
void setResultCode(String resultCode);
|
||||
|
||||
/**
|
||||
* Gets the ValueStack associated with this ActionInvocation.
|
||||
*
|
||||
* @return the ValueStack
|
||||
*/
|
||||
@Override
|
||||
ValueStack getStack();
|
||||
|
||||
/**
|
||||
* Register a {@link PreResultListener} to be notified after the Action is executed and
|
||||
* before the Result is executed.
|
||||
*
|
||||
* <p>
|
||||
* The ActionInvocation implementation must guarantee that listeners will be called in
|
||||
* the order in which they are registered.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Listener registration and execution does not need to be thread-safe.
|
||||
* </p>
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
*/
|
||||
@Override
|
||||
default void addPreResultListener(org.apache.struts2.interceptor.PreResultListener listener) {
|
||||
addPreResultListener(PreResultListener.adapt(listener));
|
||||
}
|
||||
|
||||
void addPreResultListener(PreResultListener listener);
|
||||
|
||||
/**
|
||||
* Invokes the next step in processing this ActionInvocation.
|
||||
*
|
||||
* <p>
|
||||
* If there are more Interceptors, this will call the next one. If Interceptors choose not to short-circuit
|
||||
* ActionInvocation processing and return their own return code, they will call invoke() to allow the next Interceptor
|
||||
* to execute. If there are no more Interceptors to be applied, the Action is executed.
|
||||
* If the {@link ActionProxy#getExecuteResult()} method returns <tt>true</tt>, the Result is also executed.
|
||||
* </p>
|
||||
*
|
||||
* @throws Exception can be thrown.
|
||||
* @return the return code.
|
||||
*/
|
||||
String invoke() throws Exception;
|
||||
@Override
|
||||
default void setActionEventListener(org.apache.struts2.ActionEventListener listener) {
|
||||
setActionEventListener(ActionEventListener.adapt(listener));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes only the Action (not Interceptors or Results).
|
||||
*
|
||||
* <p>
|
||||
* This is useful in rare situations where advanced usage with the interceptor/action/result workflow is
|
||||
* being manipulated for certain functionality.
|
||||
* </p>
|
||||
*
|
||||
* @return the return code.
|
||||
* @throws Exception can be thrown.
|
||||
*/
|
||||
String invokeActionOnly() throws Exception;
|
||||
|
||||
/**
|
||||
* Sets the action event listener to respond to key action events.
|
||||
*
|
||||
* @param listener the listener.
|
||||
*/
|
||||
void setActionEventListener(ActionEventListener listener);
|
||||
|
||||
void init(ActionProxy proxy) ;
|
||||
@Override
|
||||
default void init(org.apache.struts2.ActionProxy proxy) {
|
||||
init(ActionProxy.adapt(proxy));
|
||||
}
|
||||
|
||||
void init(ActionProxy proxy);
|
||||
|
||||
static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) {
|
||||
if (actualInvocation instanceof ActionInvocation) {
|
||||
return (ActionInvocation) actualInvocation;
|
||||
}
|
||||
return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null;
|
||||
}
|
||||
|
||||
class LegacyAdapter implements ActionInvocation {
|
||||
|
||||
private final org.apache.struts2.ActionInvocation adaptee;
|
||||
|
||||
private LegacyAdapter(org.apache.struts2.ActionInvocation adaptee) {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAction() {
|
||||
return adaptee.getAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExecuted() {
|
||||
return adaptee.isExecuted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext getInvocationContext() {
|
||||
return ActionContext.adapt(adaptee.getInvocationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionProxy getProxy() {
|
||||
return ActionProxy.adapt(adaptee.getProxy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getResult() throws Exception {
|
||||
return Result.adapt(adaptee.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResultCode() {
|
||||
return adaptee.getResultCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResultCode(String resultCode) {
|
||||
adaptee.setResultCode(resultCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueStack getStack() {
|
||||
return ValueStack.adapt(adaptee.getStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPreResultListener(PreResultListener listener) {
|
||||
adaptee.addPreResultListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String invoke() throws Exception {
|
||||
return adaptee.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String invokeActionOnly() throws Exception {
|
||||
return adaptee.invokeActionOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionEventListener(ActionEventListener listener) {
|
||||
adaptee.setActionEventListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ActionProxy proxy) {
|
||||
adaptee.init(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,88 +20,75 @@ package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
|
||||
/**
|
||||
* ActionProxy is an extra layer between XWork and the action so that different proxies are possible.
|
||||
*
|
||||
* <p>
|
||||
* An example of this would be a remote proxy, where the layer between XWork and the action might be RMI or SOAP.
|
||||
* </p>
|
||||
*
|
||||
* @author Jason Carreira
|
||||
*/
|
||||
public interface ActionProxy {
|
||||
@Deprecated
|
||||
public interface ActionProxy extends org.apache.struts2.ActionProxy {
|
||||
|
||||
/**
|
||||
* Gets the Action instance for this Proxy.
|
||||
*
|
||||
* @return the Action instance
|
||||
*/
|
||||
Object getAction();
|
||||
|
||||
/**
|
||||
* Gets the alias name this ActionProxy is mapped to.
|
||||
*
|
||||
* @return the alias name
|
||||
*/
|
||||
String getActionName();
|
||||
|
||||
/**
|
||||
* Gets the ActionConfig this ActionProxy is built from.
|
||||
*
|
||||
* @return the ActionConfig
|
||||
*/
|
||||
ActionConfig getConfig();
|
||||
|
||||
/**
|
||||
* Sets whether this ActionProxy should also execute the Result after executing the Action.
|
||||
*
|
||||
* @param executeResult <tt>true</tt> to also execute the Result.
|
||||
*/
|
||||
void setExecuteResult(boolean executeResult);
|
||||
|
||||
/**
|
||||
* Gets the status of whether the ActionProxy is set to execute the Result after the Action is executed.
|
||||
*
|
||||
* @return the status
|
||||
*/
|
||||
boolean getExecuteResult();
|
||||
|
||||
/**
|
||||
* Gets the ActionInvocation associated with this ActionProxy.
|
||||
*
|
||||
* @return the ActionInvocation
|
||||
*/
|
||||
@Override
|
||||
ActionInvocation getInvocation();
|
||||
|
||||
/**
|
||||
* Gets the namespace the ActionConfig for this ActionProxy is mapped to.
|
||||
*
|
||||
* @return the namespace
|
||||
*/
|
||||
String getNamespace();
|
||||
static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) {
|
||||
if (actualProxy instanceof ActionProxy) {
|
||||
return (ActionProxy) actualProxy;
|
||||
}
|
||||
return actualProxy != null ? new LegacyAdapter(actualProxy) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute this ActionProxy. This will set the ActionContext from the ActionInvocation into the ActionContext
|
||||
* ThreadLocal before invoking the ActionInvocation, then set the old ActionContext back into the ThreadLocal.
|
||||
*
|
||||
* @return the result code returned from executing the ActionInvocation
|
||||
* @throws Exception can be thrown.
|
||||
* @see ActionInvocation
|
||||
*/
|
||||
String execute() throws Exception;
|
||||
class LegacyAdapter implements ActionProxy {
|
||||
|
||||
/**
|
||||
* Gets the method name to execute, or <tt>null</tt> if no method has been specified (meaning <code>execute</code> will be invoked).
|
||||
*
|
||||
* @return the method to execute
|
||||
*/
|
||||
String getMethod();
|
||||
private final org.apache.struts2.ActionProxy adaptee;
|
||||
|
||||
/**
|
||||
* Gets status of the method value's initialization.
|
||||
*
|
||||
* @return true if the method returned by getMethod() is not a default initializer value.
|
||||
*/
|
||||
boolean isMethodSpecified();
|
||||
|
||||
private LegacyAdapter(org.apache.struts2.ActionProxy adaptee) {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAction() {
|
||||
return adaptee.getAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionName() {
|
||||
return adaptee.getActionName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionConfig getConfig() {
|
||||
return adaptee.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExecuteResult(boolean executeResult) {
|
||||
adaptee.setExecuteResult(executeResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getExecuteResult() {
|
||||
return adaptee.getExecuteResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionInvocation getInvocation() {
|
||||
return ActionInvocation.adapt(adaptee.getInvocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return adaptee.getNamespace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return adaptee.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return adaptee.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMethodSpecified() {
|
||||
return adaptee.isMethodSpecified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,342 +18,11 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import com.opensymphony.xwork2.conversion.impl.ConversionData;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.ValidationAware;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Provides a default implementation for the most common actions.
|
||||
* See the documentation for all the interfaces this class implements for more detailed information.
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.ActionSupport} instead.
|
||||
*/
|
||||
public class ActionSupport implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ActionSupport.class);
|
||||
|
||||
private final ValidationAwareSupport validationAware = new ValidationAwareSupport();
|
||||
|
||||
private transient TextProvider textProvider;
|
||||
private transient LocaleProvider localeProvider;
|
||||
|
||||
protected Container container;
|
||||
|
||||
@Override
|
||||
public void setActionErrors(Collection<String> errorMessages) {
|
||||
validationAware.setActionErrors(errorMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getActionErrors() {
|
||||
return validationAware.getActionErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionMessages(Collection<String> messages) {
|
||||
validationAware.setActionMessages(messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getActionMessages() {
|
||||
return validationAware.getActionMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFieldErrors(Map<String, List<String>> errorMap) {
|
||||
validationAware.setFieldErrors(errorMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getFieldErrors() {
|
||||
return validationAware.getFieldErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return getLocaleProvider().getLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidLocaleString(String localeStr) {
|
||||
return getLocaleProvider().isValidLocaleString(localeStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidLocale(Locale locale) {
|
||||
return getLocaleProvider().isValidLocale(locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale toLocale(String localeStr) {
|
||||
return getLocaleProvider().toLocale(localeStr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasKey(String key) {
|
||||
return getTextProvider().hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String aTextName) {
|
||||
return getTextProvider().getText(aTextName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String aTextName, String defaultValue) {
|
||||
return getTextProvider().getText(aTextName, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String aTextName, String defaultValue, String obj) {
|
||||
return getTextProvider().getText(aTextName, defaultValue, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String aTextName, List<?> args) {
|
||||
return getTextProvider().getText(aTextName, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String key, String[] args) {
|
||||
return getTextProvider().getText(key, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String aTextName, String defaultValue, List<?> args) {
|
||||
return getTextProvider().getText(aTextName, defaultValue, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String key, String defaultValue, String[] args) {
|
||||
return getTextProvider().getText(key, defaultValue, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String key, String defaultValue, List<?> args, ValueStack stack) {
|
||||
return getTextProvider().getText(key, defaultValue, args, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(String key, String defaultValue, String[] args, ValueStack stack) {
|
||||
return getTextProvider().getText(key, defaultValue, args, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dedicated method to support I10N and conversion errors
|
||||
*
|
||||
* @param key message which contains formatting string
|
||||
* @param expr that should be formatted
|
||||
* @return formatted expr with format specified by key
|
||||
*/
|
||||
public String getFormatted(String key, String expr) {
|
||||
Map<String, ConversionData> conversionErrors = ActionContext.getContext().getConversionErrors();
|
||||
if (conversionErrors.containsKey(expr)) {
|
||||
String[] vals = (String[]) conversionErrors.get(expr).getValue();
|
||||
return vals[0];
|
||||
} else {
|
||||
final ValueStack valueStack = ActionContext.getContext().getValueStack();
|
||||
final Object val = valueStack.findValue(expr);
|
||||
return getText(key, Arrays.asList(val));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceBundle getTexts() {
|
||||
return getTextProvider().getTexts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceBundle getTexts(String aBundleName) {
|
||||
return getTextProvider().getTexts(aBundleName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActionError(String anErrorMessage) {
|
||||
validationAware.addActionError(anErrorMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActionMessage(String aMessage) {
|
||||
validationAware.addActionMessage(aMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFieldError(String fieldName, String errorMessage) {
|
||||
validationAware.addFieldError(fieldName, errorMessage);
|
||||
}
|
||||
|
||||
public String input() throws Exception {
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
/**
|
||||
* A default implementation that does nothing an returns "success".
|
||||
*
|
||||
* <p>
|
||||
* Subclasses should override this method to provide their business logic.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* See also {@link com.opensymphony.xwork2.Action#execute()}.
|
||||
* </p>
|
||||
*
|
||||
* @return returns {@link #SUCCESS}
|
||||
* @throws Exception can be thrown by subclasses.
|
||||
*/
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActionErrors() {
|
||||
return validationAware.hasActionErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasActionMessages() {
|
||||
return validationAware.hasActionMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasErrors() {
|
||||
return validationAware.hasErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFieldErrors() {
|
||||
return validationAware.hasFieldErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears field errors. Useful for Continuations and other situations
|
||||
* where you might want to clear parts of the state on the same action.
|
||||
*/
|
||||
public void clearFieldErrors() {
|
||||
validationAware.clearFieldErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears action errors. Useful for Continuations and other situations
|
||||
* where you might want to clear parts of the state on the same action.
|
||||
*/
|
||||
public void clearActionErrors() {
|
||||
validationAware.clearActionErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears messages. Useful for Continuations and other situations
|
||||
* where you might want to clear parts of the state on the same action.
|
||||
*/
|
||||
public void clearMessages() {
|
||||
validationAware.clearMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all errors. Useful for Continuations and other situations
|
||||
* where you might want to clear parts of the state on the same action.
|
||||
*/
|
||||
public void clearErrors() {
|
||||
validationAware.clearErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all errors and messages. Useful for Continuations and other situations
|
||||
* where you might want to clear parts of the state on the same action.
|
||||
*/
|
||||
public void clearErrorsAndMessages() {
|
||||
validationAware.clearErrorsAndMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* A default implementation that validates nothing.
|
||||
* Subclasses should override this method to provide validations.
|
||||
*/
|
||||
@Override
|
||||
public void validate() {
|
||||
// A default implementation that validates nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: pause-method -->
|
||||
* Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return
|
||||
* the specified result, such as {@link #SUCCESS}, {@link #INPUT}, etc.
|
||||
*
|
||||
* <p>
|
||||
* The next time this action is invoked (and using the same continuation ID), the method will resume immediately
|
||||
* after where this method was called, with the entire call stack in the execute method restored.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Note: this method can <b>only</b> be called within the {@link #execute()} method.
|
||||
* </p>
|
||||
*
|
||||
* <!-- END SNIPPET: pause-method -->
|
||||
*
|
||||
* @param result the result to return - the same type of return value in the {@link #execute()} method.
|
||||
*/
|
||||
public void pause(String result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* If called first time it will create {@link com.opensymphony.xwork2.TextProviderFactory},
|
||||
* inject dependency (if {@link com.opensymphony.xwork2.inject.Container} is accesible) into in,
|
||||
* then will create new {@link com.opensymphony.xwork2.TextProvider} and store it in a field
|
||||
* for future references and at the returns reference to that field
|
||||
*
|
||||
* @return reference to field with TextProvider
|
||||
*/
|
||||
protected TextProvider getTextProvider() {
|
||||
if (textProvider == null) {
|
||||
final TextProviderFactory tpf = getContainer().getInstance(TextProviderFactory.class);
|
||||
textProvider = tpf.createInstance(getClass());
|
||||
}
|
||||
return textProvider;
|
||||
}
|
||||
|
||||
protected LocaleProvider getLocaleProvider() {
|
||||
if (localeProvider == null) {
|
||||
final LocaleProviderFactory localeProviderFactory = getContainer().getInstance(LocaleProviderFactory.class);
|
||||
localeProvider = localeProviderFactory.createLocaleProvider();
|
||||
}
|
||||
return localeProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: This a temporary solution, maybe we should consider stop injecting container into beans
|
||||
*/
|
||||
protected Container getContainer() {
|
||||
if (container == null) {
|
||||
container = ActionContext.getContext().getContainer();
|
||||
if (container != null) {
|
||||
boolean devMode = Boolean.parseBoolean(container.getInstance(String.class, StrutsConstants.STRUTS_DEVMODE));
|
||||
if (devMode) {
|
||||
LOG.warn("Container is null, action was created manually? Fallback to ActionContext");
|
||||
} else {
|
||||
LOG.debug("Container is null, action was created manually? Fallback to ActionContext");
|
||||
}
|
||||
} else {
|
||||
LOG.warn("Container is null, action was created out of ActionContext scope?!?");
|
||||
}
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public class ActionSupport extends org.apache.struts2.ActionSupport implements Action, Validateable, ValidationAware {
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import ognl.NoSuchPropertyException;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.result.ActionChainResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@@ -248,12 +249,15 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
Interceptor interceptor = interceptorMapping.getInterceptor();
|
||||
if (interceptor instanceof WithLazyParams) {
|
||||
interceptor = lazyParamInjector.injectParams(interceptor, interceptorMapping.getParams(), invocationContext);
|
||||
} else if (interceptor instanceof Interceptor.LegacyAdapter && ((Interceptor.LegacyAdapter) interceptor).getAdaptee() instanceof WithLazyParams) {
|
||||
org.apache.struts2.interceptor.Interceptor adaptee = ((Interceptor.LegacyAdapter) interceptor).getAdaptee();
|
||||
lazyParamInjector.injectParams(adaptee, interceptorMapping.getParams(), invocationContext);
|
||||
}
|
||||
if (interceptor instanceof ConditionalInterceptor) {
|
||||
resultCode = executeConditional((ConditionalInterceptor) interceptor);
|
||||
} else {
|
||||
LOG.debug("Executing normal interceptor: {}", interceptorMapping.getName());
|
||||
resultCode = interceptor.intercept(this);
|
||||
resultCode = interceptor.intercept((org.apache.struts2.ActionInvocation) this);
|
||||
}
|
||||
} else {
|
||||
resultCode = invokeActionOnly();
|
||||
@@ -294,9 +298,9 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
}
|
||||
|
||||
protected String executeConditional(ConditionalInterceptor conditionalInterceptor) throws Exception {
|
||||
if (conditionalInterceptor.shouldIntercept(this)) {
|
||||
if (conditionalInterceptor.shouldIntercept((org.apache.struts2.ActionInvocation) this)) {
|
||||
LOG.debug("Executing conditional interceptor: {}", conditionalInterceptor.getClass().getSimpleName());
|
||||
return conditionalInterceptor.intercept(this);
|
||||
return conditionalInterceptor.intercept((org.apache.struts2.ActionInvocation) this);
|
||||
} else {
|
||||
LOG.debug("Interceptor: {} is disabled, skipping to next", conditionalInterceptor.getClass().getSimpleName());
|
||||
return this.invoke();
|
||||
@@ -374,7 +378,7 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
result = createResult();
|
||||
|
||||
if (result != null) {
|
||||
result.execute(this);
|
||||
result.execute((org.apache.struts2.ActionInvocation) this);
|
||||
} else if (resultCode != null && !Action.NONE.equals(resultCode)) {
|
||||
throw new ConfigurationException("No result defined for action " + getAction().getClass().getName()
|
||||
+ " and result " + getResultCode(), proxy.getConfig());
|
||||
|
||||
@@ -19,18 +19,8 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
/**
|
||||
* ModelDriven Actions provide a model object to be pushed onto the ValueStack
|
||||
* in addition to the Action itself, allowing a FormBean type approach like Struts.
|
||||
*
|
||||
* @author Jason Carreira
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.ModelDriven} instead.
|
||||
*/
|
||||
public interface ModelDriven<T> {
|
||||
|
||||
/**
|
||||
* Gets the model to be pushed onto the ValueStack instead of the Action itself.
|
||||
*
|
||||
* @return the model
|
||||
*/
|
||||
T getModel();
|
||||
|
||||
@Deprecated
|
||||
public interface ModelDriven<T> extends org.apache.struts2.ModelDriven<T> {
|
||||
}
|
||||
|
||||
@@ -19,19 +19,8 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
/**
|
||||
* Preparable Actions will have their <code>prepare()</code> method called if the {@link com.opensymphony.xwork2.interceptor.PrepareInterceptor}
|
||||
* is applied to the ActionConfig.
|
||||
*
|
||||
* @author Jason Carreira
|
||||
* @see com.opensymphony.xwork2.interceptor.PrepareInterceptor
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.Preparable} instead.
|
||||
*/
|
||||
public interface Preparable {
|
||||
|
||||
/**
|
||||
* This method is called to allow the action to prepare itself.
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
void prepare() throws Exception;
|
||||
|
||||
@Deprecated
|
||||
public interface Preparable extends org.apache.struts2.Preparable {
|
||||
}
|
||||
|
||||
@@ -18,33 +18,39 @@
|
||||
*/
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* All results (except for <code>Action.NONE</code>) of an {@link Action} are mapped to a View implementation.
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>
|
||||
* Examples of Views might be:
|
||||
* </p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>SwingPanelView - pops up a new Swing panel</li>
|
||||
* <li>ActionChainView - executes another action</li>
|
||||
* <li>SerlvetRedirectView - redirects the HTTP response to a URL</li>
|
||||
* <li>ServletDispatcherView - dispatches the HTTP response to a URL</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author plightbo
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.result.Result} instead.
|
||||
*/
|
||||
public interface Result extends Serializable {
|
||||
@Deprecated
|
||||
public interface Result extends org.apache.struts2.result.Result {
|
||||
|
||||
@Override
|
||||
default void execute(org.apache.struts2.ActionInvocation invocation) throws Exception {
|
||||
execute(ActionInvocation.adapt(invocation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a generic interface for all action execution results.
|
||||
* Whether that be displaying a webpage, generating an email, sending a JMS message, etc.
|
||||
*
|
||||
* @param invocation the invocation context.
|
||||
* @throws Exception can be thrown.
|
||||
*/
|
||||
void execute(ActionInvocation invocation) throws Exception;
|
||||
|
||||
static Result adapt(org.apache.struts2.result.Result actualResult) {
|
||||
if (actualResult instanceof Result) {
|
||||
return (Result) actualResult;
|
||||
}
|
||||
return actualResult != null ? new LegacyAdapter(actualResult) : null;
|
||||
}
|
||||
|
||||
class LegacyAdapter implements Result {
|
||||
|
||||
private final org.apache.struts2.result.Result adaptee;
|
||||
|
||||
private LegacyAdapter(org.apache.struts2.result.Result adaptee) {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ActionInvocation invocation) throws Exception {
|
||||
adaptee.execute(ActionInvocation.adapt(invocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
/**
|
||||
* Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining.
|
||||
*
|
||||
* @see com.opensymphony.xwork2.interceptor.ChainingInterceptor
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.Unchainable} instead.
|
||||
*/
|
||||
public interface Unchainable {
|
||||
@Deprecated
|
||||
public interface Unchainable extends org.apache.struts2.Unchainable {
|
||||
}
|
||||
|
||||
@@ -19,17 +19,8 @@
|
||||
package com.opensymphony.xwork2;
|
||||
|
||||
/**
|
||||
* Provides an interface in which a call for a validation check can be done.
|
||||
*
|
||||
* @author Jason Carreira
|
||||
* @see ActionSupport
|
||||
* @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor
|
||||
* @deprecated since 6.7.0, use {@link org.apache.struts2.Validateable} instead.
|
||||
*/
|
||||
public interface Validateable {
|
||||
|
||||
/**
|
||||
* Performs validation.
|
||||
*/
|
||||
void validate();
|
||||
|
||||
@Deprecated
|
||||
public interface Validateable extends org.apache.struts2.Validateable {
|
||||
}
|
||||
|
||||
@@ -21,7 +21,12 @@ package com.opensymphony.xwork2;
|
||||
import com.opensymphony.xwork2.interceptor.ValidationAware;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Provides a default implementation of ValidationAware. Returns new collections for
|
||||
@@ -72,13 +77,7 @@ public class ValidationAwareSupport implements ValidationAware, Serializable {
|
||||
|
||||
public synchronized void addFieldError(String fieldName, String errorMessage) {
|
||||
final Map<String, List<String>> errors = internalGetFieldErrors();
|
||||
List<String> thisFieldErrors = errors.get(fieldName);
|
||||
|
||||
if (thisFieldErrors == null) {
|
||||
thisFieldErrors = new ArrayList<>();
|
||||
errors.put(fieldName, thisFieldErrors);
|
||||
}
|
||||
|
||||
List<String> thisFieldErrors = errors.computeIfAbsent(fieldName, k -> new ArrayList<>());
|
||||
thisFieldErrors.add(errorMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,21 @@
|
||||
package com.opensymphony.xwork2.config;
|
||||
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* ConfigurationUtil
|
||||
*
|
||||
*
|
||||
* @author Jason Carreira Created May 23, 2003 11:22:49 PM
|
||||
*/
|
||||
public class ConfigurationUtil {
|
||||
@@ -83,4 +86,12 @@ public class ConfigurationUtil {
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
public static Set<Class<?>> getAllClassTypes(Class<?> clazz) {
|
||||
HashSet<Class<?>> classes = new HashSet<>();
|
||||
classes.add(clazz);
|
||||
classes.addAll(ClassUtils.getAllSuperclasses(clazz));
|
||||
classes.addAll(ClassUtils.getAllInterfaces(clazz));
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,16 @@ public class InterceptorMapping implements Serializable {
|
||||
private Interceptor interceptor;
|
||||
private final Map<String, String> params;
|
||||
|
||||
public InterceptorMapping(String name, org.apache.struts2.interceptor.Interceptor interceptor) {
|
||||
this(name, Interceptor.adapt(interceptor));
|
||||
}
|
||||
|
||||
public InterceptorMapping(String name, org.apache.struts2.interceptor.Interceptor interceptor, Map<String, String> params) {
|
||||
this(name, Interceptor.adapt(interceptor), params);
|
||||
}
|
||||
|
||||
public InterceptorMapping(String name, Interceptor interceptor) {
|
||||
this(name, interceptor, new HashMap<String, String>());
|
||||
this(name, interceptor, new HashMap<>());
|
||||
}
|
||||
|
||||
public InterceptorMapping(String name, Interceptor interceptor, Map<String, String> params) {
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class ResultConfig extends Located implements Serializable {
|
||||
|
||||
protected Map<String,String> params;
|
||||
protected Map<String, String> params;
|
||||
protected String className;
|
||||
protected String name;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ResultConfig extends Located implements Serializable {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Map<String,String> getParams() {
|
||||
public Map<String, String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class ResultConfig extends Located implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addParams(Map<String,String> params) {
|
||||
public Builder addParams(Map<String, String> params) {
|
||||
target.params.putAll(params);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ import com.opensymphony.xwork2.factory.ActionFactory;
|
||||
import com.opensymphony.xwork2.factory.ConverterFactory;
|
||||
import com.opensymphony.xwork2.factory.DefaultActionFactory;
|
||||
import com.opensymphony.xwork2.factory.DefaultInterceptorFactory;
|
||||
import com.opensymphony.xwork2.factory.DefaultResultFactory;
|
||||
import com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory;
|
||||
import com.opensymphony.xwork2.factory.DefaultValidatorFactory;
|
||||
import com.opensymphony.xwork2.factory.InterceptorFactory;
|
||||
@@ -109,6 +108,7 @@ import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.conversion.StrutsConversionPropertiesProcessor;
|
||||
import org.apache.struts2.conversion.StrutsTypeConverterCreator;
|
||||
import org.apache.struts2.conversion.StrutsTypeConverterHolder;
|
||||
import org.apache.struts2.factory.StrutsResultFactory;
|
||||
import org.apache.struts2.ognl.OgnlGuard;
|
||||
import org.apache.struts2.ognl.ProviderAllowlist;
|
||||
import org.apache.struts2.ognl.StrutsOgnlGuard;
|
||||
@@ -363,7 +363,7 @@ public class DefaultConfiguration implements Configuration {
|
||||
// TODO: SpringObjectFactoryTest fails when these are SINGLETON
|
||||
.factory(ObjectFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ActionFactory.class, DefaultActionFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ResultFactory.class, DefaultResultFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ResultFactory.class, StrutsResultFactory.class, Scope.PROTOTYPE)
|
||||
.factory(InterceptorFactory.class, DefaultInterceptorFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ValidatorFactory.class, DefaultValidatorFactory.class, Scope.PROTOTYPE)
|
||||
.factory(ConverterFactory.class, StrutsConverterFactory.class, Scope.PROTOTYPE)
|
||||
|
||||
+7
-10
@@ -45,7 +45,6 @@ import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
import com.opensymphony.xwork2.util.location.LocationUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -109,6 +108,11 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
this.valueSubstitutor = valueSubstitutor;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setProviderAllowlist(ProviderAllowlist providerAllowlist) {
|
||||
this.providerAllowlist = providerAllowlist;
|
||||
}
|
||||
|
||||
public XmlDocConfigurationProvider(Document... documents) {
|
||||
this.documents = Arrays.asList(documents);
|
||||
}
|
||||
@@ -135,11 +139,6 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
private void registerAllowlist() {
|
||||
providerAllowlist = configuration.getContainer().getInstance(ProviderAllowlist.class);
|
||||
providerAllowlist.registerAllowlist(this, allowlistClasses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (providerAllowlist != null) {
|
||||
@@ -149,9 +148,8 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
|
||||
protected Class<?> allowAndLoadClass(String className) throws ClassNotFoundException {
|
||||
Class<?> clazz = loadClass(className);
|
||||
allowlistClasses.add(clazz);
|
||||
allowlistClasses.addAll(ClassUtils.getAllSuperclasses(clazz));
|
||||
allowlistClasses.addAll(ClassUtils.getAllInterfaces(clazz));
|
||||
allowlistClasses.addAll(ConfigurationUtil.getAllClassTypes(clazz));
|
||||
providerAllowlist.registerAllowlist(this, allowlistClasses);
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@@ -333,7 +331,6 @@ public abstract class XmlDocConfigurationProvider implements ConfigurationProvid
|
||||
}
|
||||
|
||||
declaredPackages.clear();
|
||||
registerAllowlist();
|
||||
configuration = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,13 +70,18 @@ public class DefaultInterceptorFactory implements InterceptorFactory {
|
||||
reflectionProvider.setProperties(params, o);
|
||||
}
|
||||
|
||||
Interceptor interceptor = null;
|
||||
if (o instanceof Interceptor) {
|
||||
Interceptor interceptor = (Interceptor) o;
|
||||
interceptor.init();
|
||||
return interceptor;
|
||||
interceptor = (Interceptor) o;
|
||||
} else if (o instanceof org.apache.struts2.interceptor.Interceptor) {
|
||||
interceptor = Interceptor.adapt((org.apache.struts2.interceptor.Interceptor) o);
|
||||
}
|
||||
|
||||
throw new ConfigurationException("Class [" + interceptorClassName + "] does not implement Interceptor", interceptorConfig);
|
||||
if (interceptor == null) {
|
||||
throw new ConfigurationException("Class [" + interceptorClassName + "] does not implement Interceptor", interceptorConfig);
|
||||
}
|
||||
interceptor.init();
|
||||
return interceptor;
|
||||
} catch (InstantiationException e) {
|
||||
cause = e;
|
||||
message = "Unable to instantiate an instance of Interceptor class [" + interceptorClassName + "].";
|
||||
|
||||
@@ -20,17 +20,22 @@ package com.opensymphony.xwork2.factory;
|
||||
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.Result;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionException;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler;
|
||||
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
|
||||
import org.apache.struts2.factory.StrutsResultFactory;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Default implementation
|
||||
*
|
||||
* @deprecated since 6.7.0, use {@link StrutsResultFactory} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultResultFactory implements ResultFactory {
|
||||
|
||||
private ObjectFactory objectFactory;
|
||||
@@ -51,19 +56,29 @@ public class DefaultResultFactory implements ResultFactory {
|
||||
Result result = null;
|
||||
|
||||
if (resultClassName != null) {
|
||||
result = (Result) objectFactory.buildBean(resultClassName, extraContext);
|
||||
Object o = objectFactory.buildBean(resultClassName, extraContext);
|
||||
|
||||
Map<String, String> params = resultConfig.getParams();
|
||||
if (params != null) {
|
||||
for (Map.Entry<String, String> paramEntry : params.entrySet()) {
|
||||
try {
|
||||
reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true);
|
||||
reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), o, extraContext, true);
|
||||
} catch (ReflectionException ex) {
|
||||
if (result instanceof ReflectionExceptionHandler) {
|
||||
((ReflectionExceptionHandler) result).handle(ex);
|
||||
if (o instanceof ReflectionExceptionHandler) {
|
||||
((ReflectionExceptionHandler) o).handle(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (o instanceof Result) {
|
||||
result = (Result) o;
|
||||
} else if (o instanceof org.apache.struts2.result.Result) {
|
||||
result = Result.adapt((org.apache.struts2.result.Result) o);
|
||||
}
|
||||
if (result == null) {
|
||||
throw new ConfigurationException("Class [" + resultClassName + "] does not implement Result", resultConfig);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -242,6 +242,41 @@ class ContainerImpl implements Container {
|
||||
return toArray(parameterInjectors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets parameter injectors with nulls for optional dependencies.
|
||||
*
|
||||
* @param member to which the parameters belong
|
||||
* @param annotations on the parameters
|
||||
* @param parameterTypes parameter types
|
||||
* @return injections
|
||||
*/
|
||||
<M extends AccessibleObject & Member> ParameterInjector<?>[] getParametersInjectorsWithNulls(
|
||||
M member,
|
||||
Annotation[][] annotations,
|
||||
Class<?>[] parameterTypes,
|
||||
String defaultName
|
||||
) throws MissingDependencyException {
|
||||
final List<ParameterInjector<?>> parameterInjectors = new ArrayList<>();
|
||||
|
||||
final Iterator<Annotation[]> annotationsIterator = Arrays.asList(annotations).iterator();
|
||||
for (Class<?> parameterType : parameterTypes) {
|
||||
Inject annotation = findInject(annotationsIterator.next());
|
||||
String name = annotation == null ? defaultName : annotation.value();
|
||||
Key<?> key = Key.newInstance(parameterType, name);
|
||||
try {
|
||||
parameterInjectors.add(createParameterInjector(key, member));
|
||||
} catch (MissingDependencyException e) {
|
||||
if (annotation != null && annotation.required()) {
|
||||
throw e;
|
||||
} else {
|
||||
parameterInjectors.add(createNullParameterInjector(key, member));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toArray(parameterInjectors);
|
||||
}
|
||||
|
||||
<T> ParameterInjector<T> createParameterInjector(Key<T> key, Member member) throws MissingDependencyException {
|
||||
final InternalFactory<? extends T> factory = getFactory(key);
|
||||
if (factory == null) {
|
||||
@@ -252,6 +287,23 @@ class ContainerImpl implements Container {
|
||||
return new ParameterInjector<>(externalContext, factory);
|
||||
}
|
||||
|
||||
<T> ParameterInjector<T> createNullParameterInjector(Key<T> key, Member member) throws MissingDependencyException {
|
||||
final InternalFactory<? extends T> factory = new InternalFactory<T>() {
|
||||
@Override
|
||||
public T create(InternalContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends T> type() {
|
||||
return key.getType();
|
||||
}
|
||||
};
|
||||
|
||||
final ExternalContext<T> externalContext = ExternalContext.newInstance(member, key, this);
|
||||
return new ParameterInjector<>(externalContext, factory);
|
||||
}
|
||||
|
||||
private ParameterInjector<?>[] toArray(List<ParameterInjector<?>> parameterInjections) {
|
||||
return parameterInjections.toArray(new ParameterInjector[0]);
|
||||
}
|
||||
@@ -361,7 +413,7 @@ class ContainerImpl implements Container {
|
||||
Inject inject, ContainerImpl container, Constructor<T> constructor) throws MissingDependencyException {
|
||||
return constructor.getParameterTypes().length == 0
|
||||
? null // default constructor.
|
||||
: container.getParametersInjectors(
|
||||
: container.getParametersInjectorsWithNulls(
|
||||
constructor,
|
||||
constructor.getParameterAnnotations(),
|
||||
constructor.getParameterTypes(),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user