struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r440388 - in /struts/struts2/trunk/apps/blank: ./ src/main/java/example/ src/main/java/org/apache/struts2/ src/main/java/tutorial/ src/main/resources/ src/main/webapp/ src/main/webapp/example/ src/main/webapp/tutorial/ src/test/java/example...
Date Tue, 05 Sep 2006 16:37:22 GMT
Author: husted
Date: Tue Sep  5 09:37:18 2006
New Revision: 440388

URL: http://svn.apache.org/viewvc?view=rev&rev=440388
Log:
WW-1340 Add "tutorial" module to blank, corresponding with "Bootstrap" tutorial in documentation.

Added:
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/
      - copied from r440152, struts/struts2/trunk/apps/blank/src/main/java/example/
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java   (with props)
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login-validation.xml
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login.java
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/TutorialSupport.java
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/package.properties
    struts/struts2/trunk/apps/blank/src/main/resources/tutorial.xml
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/
      - copied from r440152, struts/struts2/trunk/apps/blank/src/main/webapp/example/
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp   (with props)
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Login.jsp
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Menu.jsp
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Missing.jsp
    struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Welcome.jsp
    struts/struts2/trunk/apps/blank/src/test/java/tutorial/
      - copied from r440152, struts/struts2/trunk/apps/blank/src/test/java/example/
    struts/struts2/trunk/apps/blank/src/test/java/tutorial/ConfigTest.java
    struts/struts2/trunk/apps/blank/src/test/java/tutorial/HelloWorldTest.java
    struts/struts2/trunk/apps/blank/src/test/java/tutorial/LoginTest.java
Removed:
    struts/struts2/trunk/apps/blank/src/main/java/example/
    struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/
    struts/struts2/trunk/apps/blank/src/main/java/tutorial/Welcome.java
    struts/struts2/trunk/apps/blank/src/main/webapp/example/
    struts/struts2/trunk/apps/blank/src/test/java/example/
    struts/struts2/trunk/apps/blank/src/test/java/org/apache/struts2/
    struts/struts2/trunk/apps/blank/src/test/java/tutorial/WelcomeTest.java
Modified:
    struts/struts2/trunk/apps/blank/pom.xml
    struts/struts2/trunk/apps/blank/src/main/resources/struts.xml
    struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp

Modified: struts/struts2/trunk/apps/blank/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/pom.xml?view=diff&rev=440388&r1=440387&r2=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/pom.xml (original)
+++ struts/struts2/trunk/apps/blank/pom.xml Tue Sep  5 09:37:18 2006
@@ -3,25 +3,25 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
-      <groupId>org.apache.struts</groupId>
-      <artifactId>struts2-apps</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-apps</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
     </parent>
     <groupId>org.apache.struts</groupId>
     <artifactId>struts2-blank</artifactId>
     <packaging>war</packaging>
     <name>Blank Webapp</name>
     <dependencies>
-      
-      <dependency>
-         <groupId>javax.servlet</groupId>
-         <artifactId>servlet-api</artifactId>
-         <version>2.4</version>
-         <scope>provided</scope>
-      </dependency>
-      
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
+
     </dependencies>
-    
+
     <build>
         <plugins>
             <plugin>
@@ -41,6 +41,6 @@
             </plugin>
         </plugins>
     </build>
-    
-    
+
+
 </project>

Added: struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java (added)
+++ struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java Tue Sep  5 09:37:18
2006
@@ -0,0 +1,37 @@
+package tutorial;
+
+/**
+ * <code>Set welcome message.</code>
+ */
+public class HelloWorld extends TutorialSupport {
+
+    public static final String MESSAGE = "HelloWorld.message";
+
+    public String execute() throws Exception {
+        setMessage(getText(MESSAGE));
+        return SUCCESS;
+    }
+
+    /**
+     * Field for Message property.
+     */
+    private String message;
+
+    /**
+     * Return Message property.
+     *
+     * @return Message property
+     */
+    public String getMessage() {
+        return message;
+    }
+
+    /**
+     * Set Message property.
+     *
+     * @param message Text to display on HelloWorld page.
+     */
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

Propchange: struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/struts2/trunk/apps/blank/src/main/java/tutorial/HelloWorld.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login-validation.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login-validation.xml?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login-validation.xml (added)
+++ struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login-validation.xml Tue Sep  5
09:37:18 2006
@@ -0,0 +1,16 @@
+<!DOCTYPE validators PUBLIC
+        "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+        "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+    <field name="username">
+        <field-validator type="requiredstring">
+            <message key="username.required"/>
+        </field-validator>
+    </field>
+    <field name="password">
+        <field-validator type="requiredstring">
+            <message key="password.required"/>
+        </field-validator>
+    </field>
+</validators>

Added: struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login.java (added)
+++ struts/struts2/trunk/apps/blank/src/main/java/tutorial/Login.java Tue Sep  5 09:37:18
2006
@@ -0,0 +1,38 @@
+package tutorial;
+
+public class Login extends TutorialSupport {
+
+    public String execute() throws Exception {
+
+        if (isInvalid(getUsername())) return INPUT;
+
+        if (isInvalid(getPassword())) return INPUT;
+
+        return SUCCESS;
+    }
+
+    private boolean isInvalid(String value) {
+        return (value == null || value.length() == 0);
+    }
+
+    private String username;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    private String password;
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+}
\ No newline at end of file

Added: struts/struts2/trunk/apps/blank/src/main/java/tutorial/TutorialSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/tutorial/TutorialSupport.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/java/tutorial/TutorialSupport.java (added)
+++ struts/struts2/trunk/apps/blank/src/main/java/tutorial/TutorialSupport.java Tue Sep  5
09:37:18 2006
@@ -0,0 +1,9 @@
+package tutorial;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * Base Action class for the Tutorial package.
+ */
+public class TutorialSupport extends ActionSupport {
+}

Added: struts/struts2/trunk/apps/blank/src/main/java/tutorial/package.properties
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/tutorial/package.properties?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/java/tutorial/package.properties (added)
+++ struts/struts2/trunk/apps/blank/src/main/java/tutorial/package.properties Tue Sep  5 09:37:18
2006
@@ -0,0 +1,7 @@
+password = Password
+password.required = Password is required.
+username = User Name
+username.required = User Name is required.
+HelloWorld.message= Struts is up and running ...
+Missing.message =  This feature is under construction. Please try again in the next interation.
+

Modified: struts/struts2/trunk/apps/blank/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/resources/struts.xml?view=diff&rev=440388&r1=440387&r2=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/resources/struts.xml (original)
+++ struts/struts2/trunk/apps/blank/src/main/resources/struts.xml Tue Sep  5 09:37:18 2006
@@ -1,16 +1,13 @@
 <!DOCTYPE struts PUBLIC
-    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
-    "http://struts.apache.org/dtds/struts-2.0.dtd">
+        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+        "http://struts.apache.org/dtds/struts-2.0.dtd">
 
 <struts>
+
     <include file="struts-default.xml"/>
 
-    <package name="example" extends="struts-default">
+    <include file="tutorial.xml"/>
 
-        <action name="*" class="example.{1}">
-            <result>/example/{1}.jsp</result>
-        </action>
+    <!-- Add packages here -->
 
-        <!-- Add your actions here -->
-    </package>
 </struts>

Added: struts/struts2/trunk/apps/blank/src/main/resources/tutorial.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/resources/tutorial.xml?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/resources/tutorial.xml (added)
+++ struts/struts2/trunk/apps/blank/src/main/resources/tutorial.xml Tue Sep  5 09:37:18 2006
@@ -0,0 +1,24 @@
+<!DOCTYPE struts PUBLIC
+        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+        "http://struts.apache.org/dtds/struts-2.0.dtd">
+
+<struts>
+
+    <package name="tutorial" namespace="/tutorial" extends="struts-default">
+
+        <action name="HelloWorld" class="tutorial.HelloWorld">
+            <result>/tutorial/HelloWorld.jsp</result>
+        </action>
+
+        <action name="Login!*" method="{1}" class="tutorial.Login">
+            <result name="input">/tutorial/Login.jsp</result>
+            <result type="redirect-action">Menu</result>
+        </action>
+
+        <action name="*" class="tutorial.TutorialSupport">
+            <result>/tutorial/{1}.jsp</result>
+        </action>
+
+        <!-- Add actions here -->
+    </package>
+</struts>

Modified: struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp?view=diff&rev=440388&r1=440387&r2=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp (original)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp Tue Sep  5 09:37:18 2006
@@ -1 +1,11 @@
-<% response.sendRedirect(request.getContextPath() + "/Welcome.action"); %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=<s:url action="Welcome" namespace="tutorial"/>">
+</head>
+
+<body>
+<p>Loading ...</p>
+</body>
+</html>

Added: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp Tue Sep  5 09:37:18
2006
@@ -0,0 +1,11 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<html>
+<head>
+    <title>Hello World!</title>
+</head>
+
+<body>
+<h2><s:property value="message"/></h2>
+</body>
+</html>

Propchange: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/HelloWorld.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Login.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Login.jsp?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Login.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Login.jsp Tue Sep  5 09:37:18
2006
@@ -0,0 +1,15 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<html>
+<head>
+    <title>Logon</title>
+</head>
+
+<body>
+<s:form action="Login">
+    <s:textfield label="%{getText('username')}" name="username"/>
+    <s:textfield label="%{getText('password')}" name="password"/>
+    <s:submit/>
+</s:form>
+</body>
+</html>

Added: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Menu.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Menu.jsp?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Menu.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Menu.jsp Tue Sep  5 09:37:18
2006
@@ -0,0 +1,3 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<s:include value="Missing.jsp"/>
\ No newline at end of file

Added: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Missing.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Missing.jsp?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Missing.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Missing.jsp Tue Sep  5 09:37:18
2006
@@ -0,0 +1,11 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<html>
+<head><title>Missing Feature</title></head>
+
+<body>
+<p>
+    <s:text name="Missing.message"/>
+</p>
+</body>
+</html>

Added: struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Welcome.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Welcome.jsp?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Welcome.jsp (added)
+++ struts/struts2/trunk/apps/blank/src/main/webapp/tutorial/Welcome.jsp Tue Sep  5 09:37:18
2006
@@ -0,0 +1,35 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<html>
+<head>
+    <title>Welcome</title>
+    <link href="<s:url value="/css/tutorial.css"/>" rel="stylesheet"
+          type="text/css"/>
+</head>
+
+<body>
+<h3>Commands</h3>
+<ul>
+    <li><a href="<s:url action="Register"/>">Register</a></li>
+    <li><a href="<s:url action="Login!input"/>">Sign On</a></li>
+</ul>
+
+<h3>Languages</h3>
+<ul>
+    <li>
+        <s:url id="url" action="Welcome">
+            <s:param name="request_locale">en</s:param>
+        </s:url>
+        <s:a href="%{url}">English</s:a>
+    </li>
+    <li>
+        <s:url id="url" action="Welcome">
+            <s:param name="request_locale">ja</s:param>
+        </s:url>
+        <s:a href="%{url}">Japanese</s:a>
+    </li>
+</ul>
+
+</body>
+</html>
+

Added: struts/struts2/trunk/apps/blank/src/test/java/tutorial/ConfigTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/test/java/tutorial/ConfigTest.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/test/java/tutorial/ConfigTest.java (added)
+++ struts/struts2/trunk/apps/blank/src/test/java/tutorial/ConfigTest.java Tue Sep  5 09:37:18
2006
@@ -0,0 +1,50 @@
+package tutorial;
+
+import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.XWorkTestCase;
+import com.opensymphony.xwork2.config.RuntimeConfiguration;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+
+import java.util.Map;
+
+public class ConfigTest extends XWorkTestCase {
+
+    protected void AssertSuccess(String result) throws Exception {
+        assertTrue("Expected a success result!",
+                ActionSupport.SUCCESS.equals(result));
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        XmlConfigurationProvider c = new XmlConfigurationProvider("struts.xml");
+        configurationManager.addConfigurationProvider(c);
+        configurationManager.reload();
+    }
+
+    protected ActionConfig assertClass(String action_name, String class_name) {
+        RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration();
+        ActionConfig config = configuration.getActionConfig("", action_name);
+        assertNotNull("Mssing action", config);
+        assertTrue("Wrong class name: [" + config.getClassName() + "]",
+                class_name.equals(config.getClassName()));
+        return config;
+    }
+
+    protected void assertResult(ActionConfig config, String result_name, String result_value)
{
+        Map results = config.getResults();
+        ResultConfig result = (ResultConfig) results.get(result_name);
+        Map params = result.getParams();
+        String value = (String) params.get("actionName");
+        if (value == null)
+            value = (String) params.get("location");
+        assertTrue("Wrong result value: [" + value + "]",
+                result_value.equals(value));
+    }
+
+    public void testConfig() throws Exception {
+        assertNotNull(configurationManager);
+    }
+
+}

Added: struts/struts2/trunk/apps/blank/src/test/java/tutorial/HelloWorldTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/test/java/tutorial/HelloWorldTest.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/test/java/tutorial/HelloWorldTest.java (added)
+++ struts/struts2/trunk/apps/blank/src/test/java/tutorial/HelloWorldTest.java Tue Sep  5
09:37:18 2006
@@ -0,0 +1,16 @@
+package tutorial;
+
+import com.opensymphony.xwork2.ActionSupport;
+import junit.framework.TestCase;
+
+public class HelloWorldTest extends TestCase {
+
+    public void testHelloWorld() throws Exception {
+        HelloWorld hello_world = new HelloWorld();
+        String result = hello_world.execute();
+        assertTrue("Expected a success result!",
+                ActionSupport.SUCCESS.equals(result));
+        assertTrue("Expected the default message!",
+                hello_world.getText(HelloWorld.MESSAGE).equals(hello_world.getMessage()));
+    }
+}

Added: struts/struts2/trunk/apps/blank/src/test/java/tutorial/LoginTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/test/java/tutorial/LoginTest.java?view=auto&rev=440388
==============================================================================
--- struts/struts2/trunk/apps/blank/src/test/java/tutorial/LoginTest.java (added)
+++ struts/struts2/trunk/apps/blank/src/test/java/tutorial/LoginTest.java Tue Sep  5 09:37:18
2006
@@ -0,0 +1,22 @@
+package tutorial;
+
+import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+
+public class LoginTest extends ConfigTest {
+
+    public void FIXME_testLoginConfig() throws Exception {
+        ActionConfig config = assertClass("Login", "tutorial.Login");
+        assertResult(config, ActionSupport.SUCCESS, "Menu");
+        assertResult(config, ActionSupport.INPUT, "/tutorial/Login.jsp");
+    }
+
+    public void testLoginSubmit() throws Exception {
+        Login login = new Login();
+        login.setUsername("username");
+        login.setPassword("password");
+        String result = login.execute();
+        AssertSuccess(result);
+    }
+
+}



Mime
View raw message