Adds action chaining example
Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/7882b0de Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/7882b0de Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/7882b0de Branch: refs/heads/master Commit: 7882b0de502250d647ca1f2e84d2b7605519209c Parents: 7a58d1e Author: Lukasz Lenart <[email protected]> Authored: Tue Mar 28 10:35:44 2017 +0200 Committer: Lukasz Lenart <[email protected]> Committed: Tue Mar 28 10:35:44 2017 +0200 ---------------------------------------------------------------------- action-chaining/pom.xml | 47 ++++++++++++++++++++ .../org/apache/struts_examples/ActionA.java | 41 +++++++++++++++++ .../org/apache/struts_examples/ActionB.java | 41 +++++++++++++++++ action-chaining/src/main/resources/struts.xml | 31 +++++++++++++ .../src/main/webapp/WEB-INF/ActionB.jsp | 14 ++++++ .../src/main/webapp/WEB-INF/index.jsp | 13 ++++++ action-chaining/src/main/webapp/WEB-INF/web.xml | 23 ++++++++++ 7 files changed, 210 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/pom.xml ---------------------------------------------------------------------- diff --git a/action-chaining/pom.xml b/action-chaining/pom.xml new file mode 100644 index 0000000..b5d17df --- /dev/null +++ b/action-chaining/pom.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>struts-examples</artifactId> + <groupId>org.apache.struts</groupId> + <version>1.0.0</version> + </parent> + + <artifactId>action-chaining</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>war</packaging> + <name>Action chaining</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <encoding>UTF-8</encoding> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>8.1.16.v20140903</version> + <configuration> + <stopKey>CTRL+C</stopKey> + <stopPort>8999</stopPort> + <scanIntervalSeconds>10</scanIntervalSeconds> + <webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory> + <webAppConfig> + <descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor> + </webAppConfig> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/java/org/apache/struts_examples/ActionA.java ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/java/org/apache/struts_examples/ActionA.java b/action-chaining/src/main/java/org/apache/struts_examples/ActionA.java new file mode 100644 index 0000000..3b85511 --- /dev/null +++ b/action-chaining/src/main/java/org/apache/struts_examples/ActionA.java @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * 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 org.apache.struts_examples; + +import com.opensymphony.xwork2.ActionSupport; + +public class ActionA extends ActionSupport { + + private String name; + + public String execute() throws Exception { + return SUCCESS; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/java/org/apache/struts_examples/ActionB.java ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/java/org/apache/struts_examples/ActionB.java b/action-chaining/src/main/java/org/apache/struts_examples/ActionB.java new file mode 100644 index 0000000..1daaa46 --- /dev/null +++ b/action-chaining/src/main/java/org/apache/struts_examples/ActionB.java @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * 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 org.apache.struts_examples; + +import com.opensymphony.xwork2.ActionSupport; + +public class ActionB extends ActionSupport { + + private String name; + + public String execute() throws Exception { + return SUCCESS; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/resources/struts.xml ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/resources/struts.xml b/action-chaining/src/main/resources/struts.xml new file mode 100644 index 0000000..7e425ec --- /dev/null +++ b/action-chaining/src/main/resources/struts.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" + "http://struts.apache.org/dtds/struts-2.5.dtd"> +<struts> + <constant name="struts.enable.DynamicMethodInvocation" value="false"/> + <constant name="struts.devMode" value="true"/> + + <package name="default" namespace="/" extends="struts-default"> + + <default-action-ref name="index"/> + + <action name="index"> + <result>WEB-INF/index.jsp</result> + </action> + + <action name="actionA" class="org.apache.struts_examples.ActionA"> + <param name="name">Chain from A to B</param> + <result name="success" type="chain"> + <param name="actionName">actionB</param> + </result> + </action> + + <action name="actionB" class="org.apache.struts_examples.ActionB"> + <result>WEB-INF/ActionB.jsp</result> + </action> + + </package> + + <!-- Add addition packages and configuration here. --> +</struts> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/webapp/WEB-INF/ActionB.jsp ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/webapp/WEB-INF/ActionB.jsp b/action-chaining/src/main/webapp/WEB-INF/ActionB.jsp new file mode 100644 index 0000000..30027af --- /dev/null +++ b/action-chaining/src/main/webapp/WEB-INF/ActionB.jsp @@ -0,0 +1,14 @@ +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<html> +<head> + <title>Action B</title> +</head> + +<body> + +<h2>Value from Action A: <s:property value="name"/></h2> + + +</body> +</html> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/webapp/WEB-INF/index.jsp ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/webapp/WEB-INF/index.jsp b/action-chaining/src/main/webapp/WEB-INF/index.jsp new file mode 100644 index 0000000..440030f --- /dev/null +++ b/action-chaining/src/main/webapp/WEB-INF/index.jsp @@ -0,0 +1,13 @@ +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<html> +<head> + <title>Action Chaining</title> +</head> + +<body> + +<s:a action="actionA">Action A</s:a> + +</body> +</html> http://git-wip-us.apache.org/repos/asf/struts-examples/blob/7882b0de/action-chaining/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/action-chaining/src/main/webapp/WEB-INF/web.xml b/action-chaining/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..8858656 --- /dev/null +++ b/action-chaining/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app id="struts_blank" version="2.4" + xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + <display-name>Struts Blank</display-name> + + <filter> + <filter-name>struts2</filter-name> + <filter-class> + org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter + </filter-class> + </filter> + + <filter-mapping> + <filter-name>struts2</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + </welcome-file-list> +</web-app>
