struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r392086 - in /struts/sandbox/trunk/mailreader-course/action2: lab-1-0/ lab-1-3/src/java/ lab-2-1/src/java/ lab-2-2/src/java/ lab-2-3/ lab-2-3/src/java/ lab-2-3/src/webapp/pages/
Date Thu, 06 Apr 2006 21:39:40 GMT
Author: husted
Date: Thu Apr  6 14:39:37 2006
New Revision: 392086

URL: http://svn.apache.org/viewcvs?rev=392086&view=rev
Log:
MailReader Course
* Add completed Lab 2-3 (half-way point)




Added:
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-3.iml
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml 
 (with props)
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java   (with props)
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java   (with props)
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp   (with
props)
Removed:
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-2.iml
Modified:
    struts/sandbox/trunk/mailreader-course/action2/lab-1-0/lab-1-0.iml
    struts/sandbox/trunk/mailreader-course/action2/lab-1-3/src/java/MailReaderSupport.java
    struts/sandbox/trunk/mailreader-course/action2/lab-2-1/src/java/MailReaderSupport.java
    struts/sandbox/trunk/mailreader-course/action2/lab-2-2/src/java/MailReaderSupport.java
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/MailReaderSupport.java
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Register.java
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/xwork.xml
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Menu.jsp
    struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Welcome.jsp

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-1-0/lab-1-0.iml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-1-0/lab-1-0.iml?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-1-0/lab-1-0.iml (original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-1-0/lab-1-0.iml Thu Apr  6 14:39:37
2006
@@ -9,6 +9,7 @@
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/exploded" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-1-3/src/java/MailReaderSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-1-3/src/java/MailReaderSupport.java?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-1-3/src/java/MailReaderSupport.java
(original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-1-3/src/java/MailReaderSupport.java
Thu Apr  6 14:39:37 2006
@@ -71,17 +71,19 @@
         replyToAddress = value;
     }
 
-    // ---- Messages ----
+    // ---- Keys ----
 
     public static final String DATABASE_KEY = "database";
 
+    public static final String USER_KEY = "user";
+
+    // ---- Messages ----
+
     public static final String ERROR_DATABASE_MISSING =
             "Database is missing";
 
     public static String ERROR_USERNAME_UNIQUE =
             "That username is already in use - please select another";
-
-    public static final String USER_KEY = "user";
 
     // ---- ApplicationAware ----
 

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-1/src/java/MailReaderSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-1/src/java/MailReaderSupport.java?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-1/src/java/MailReaderSupport.java
(original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-1/src/java/MailReaderSupport.java
Thu Apr  6 14:39:37 2006
@@ -71,17 +71,19 @@
         replyToAddress = value;
     }
 
-    // ---- Messages ----
+    // ---- Keys ----
 
     public static final String DATABASE_KEY = "database";
 
+    public static final String USER_KEY = "user";
+
+    // ---- Messages ----
+
     public static final String ERROR_DATABASE_MISSING =
             "Database is missing";
 
     public static String ERROR_USERNAME_UNIQUE =
             "That username is already in use - please select another";
-
-    public static final String USER_KEY = "user";
 
     // ---- ApplicationAware ----
 

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-2/src/java/MailReaderSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-2/src/java/MailReaderSupport.java?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-2/src/java/MailReaderSupport.java
(original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-2/src/java/MailReaderSupport.java
Thu Apr  6 14:39:37 2006
@@ -71,17 +71,19 @@
         replyToAddress = value;
     }
 
-    // ---- Messages ----
+    // ---- Keys ----
 
     public static final String DATABASE_KEY = "database";
 
+    public static final String USER_KEY = "user";
+
+    // ---- Messages ----
+
     public static final String ERROR_DATABASE_MISSING =
             "Database is missing";
 
     public static String ERROR_USERNAME_UNIQUE =
             "That username is already in use - please select another";
-
-    public static final String USER_KEY = "user";
 
     // ---- ApplicationAware ----
 

Added: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-3.iml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-3.iml?rev=392086&view=auto
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-3.iml (added)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/lab-2-3.iml Thu Apr  6 14:39:37
2006
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="J2EE_WEB_MODULE" j2ee-integration="Tomcat
Server">
+  <component name="ModuleRootManager" />
+  <component name="NewModuleRootManager">
+    <output url="file://C:/opt/Apache/Tomcat-5.0/webapps/lab-2-3/WEB-INF/classes" />
+    <exclude-output />
+    <exploded url="file://C:/opt/Apache/Tomcat-5.0/webapps/lab-2-3" />
+    <exclude-exploded />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Tomcat" level="application_server_libraries" />
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/spring-core.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/rife-continuations.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/struts-taglib-1.3.0.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/spring-context.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/oscore.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/commons-collections-3.1.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/struts-mailreader-dao-1.3.0-dev.jar!/"
/>
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/webwork-2.2.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/spring-beans.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/ognl.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/commons-digester-1.6.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/spring-web.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/commons-logging-1.0.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/xwork-1.1.2.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/../../lib/freemarker.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library>
+        <CLASSES>
+          <root url="jar://$APPLICATION_HOME_DIR$/lib/junit.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
+    <orderEntryProperties />
+  </component>
+  <component name="WebModuleBuildComponent">
+    <setting name="EXPLODED_URL" value="file://C:/opt/Apache/Tomcat-5.0/webapps/lab-2-3"
/>
+    <setting name="EXPLODED_ENABLED" value="true" />
+    <setting name="JAR_URL" value="file://" />
+    <setting name="JAR_ENABLED" value="false" />
+    <setting name="SYNC_EXPLODED_DIR" value="true" />
+    <setting name="BUILD_ON_FRAME_DEACTIVATION" value="false" />
+    <setting name="RUN_JASPER_VALIDATION" value="false" />
+  </component>
+  <component name="WebModuleProperties">
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+      <url>jar://$APPLICATION_HOME_DIR$/lib/junit.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/commons-collections-3.1.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/commons-collections-3.1.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/commons-digester-1.6.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/commons-digester-1.6.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/commons-logging-1.0.4.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/commons-logging-1.0.4.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/freemarker.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/freemarker.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/ognl.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/ognl.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/oscore.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/oscore.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/rife-continuations.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/rife-continuations.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/spring-beans.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/spring-beans.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/spring-context.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/spring-context.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/spring-core.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/spring-core.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/spring-web.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/spring-web.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/struts-mailreader-dao-1.3.0-dev.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/struts-mailreader-dao-1.3.0-dev.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/struts-taglib-1.3.0.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/struts-taglib-1.3.0.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/webwork-2.2.2.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/webwork-2.2.2.jar!/</url>
+    </containerElement>
+    <containerElement type="library" level="module">
+      <attribute name="method" value="1" />
+      <attribute name="URI" value="/WEB-INF/lib/xwork-1.1.2.jar" />
+      <url>jar://$MODULE_DIR$/../../lib/xwork-1.1.2.jar!/</url>
+    </containerElement>
+    <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/webapp/WEB-INF/web.xml"
optional="false" version="2.3" />
+    <deploymentDescriptor name="context.xml" url="file://$MODULE_DIR$/META-INF/context.xml"
optional="false" version="5.x" />
+    <webroots>
+      <root url="file://$MODULE_DIR$/src/webapp" relative="/" />
+    </webroots>
+  </component>
+  <component name="WeblogicWebModuleProperties">
+    <option name="IS_RUN_APPC" value="false" />
+  </component>
+</module>
+

Added: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml?rev=392086&view=auto
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml (added)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml Thu
Apr  6 14:39:37 2006
@@ -0,0 +1,14 @@
+<!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>Username is required</message>
+        </field-validator>
+    </field>
+    <field name="password">
+        <field-validator type="requiredstring">
+            <message>Password is required</message>
+        </field-validator>
+    </field>
+</validators>

Propchange: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login-validation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java?rev=392086&view=auto
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java (added)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java Thu Apr  6
14:39:37 2006
@@ -0,0 +1,22 @@
+import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
+import org.apache.struts.apps.mailreader.dao.User;
+
+public class Login extends MailReaderSupport {
+
+    public String execute() throws ExpiredPasswordException {
+
+        User user = findUser(getUsername(), getPassword());
+
+        if (user != null) {
+            setUser(user);
+        }
+
+        if (hasErrors()) {
+            return INPUT;
+        }
+
+        return SUCCESS;
+
+    }
+
+}

Propchange: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Login.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java?rev=392086&view=auto
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java (added)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java Thu Apr  6
14:39:37 2006
@@ -0,0 +1,9 @@
+public class Logout extends MailReaderSupport {
+
+    public String execute() {
+
+        setUser(null);
+
+        return SUCCESS;
+    }
+}

Propchange: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Logout.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/MailReaderSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/MailReaderSupport.java?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/MailReaderSupport.java
(original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/MailReaderSupport.java
Thu Apr  6 14:39:37 2006
@@ -1,5 +1,6 @@
 import com.opensymphony.util.BeanUtils;
 import com.opensymphony.webwork.interceptor.ApplicationAware;
+import com.opensymphony.webwork.interceptor.SessionAware;
 import com.opensymphony.xwork.ActionSupport;
 import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
 import org.apache.struts.apps.mailreader.dao.User;
@@ -7,7 +8,8 @@
 
 import java.util.Map;
 
-public class MailReaderSupport extends ActionSupport implements ApplicationAware {
+public class MailReaderSupport extends ActionSupport
+        implements ApplicationAware, SessionAware {
 
     // ---- Register form properties ----
 
@@ -71,17 +73,26 @@
         replyToAddress = value;
     }
 
-    // ---- Messages ----
+    // ---- Keys ----
 
     public static final String DATABASE_KEY = "database";
 
+    public static final String USER_KEY = "user";
+
+    public static final String PASSWORD_MISMATCH_FIELD = "password";
+
+    public static final String CANCEL = "cancel";
+
+    // ---- Messages ----
+
     public static final String ERROR_DATABASE_MISSING =
             "Database is missing";
 
-    public static String ERROR_USERNAME_UNIQUE =
+    public static final String ERROR_USERNAME_UNIQUE =
             "That username is already in use - please select another";
 
-    public static final String USER_KEY = "user";
+    public static final String ERROR_PASSWORD_MISMATCH =
+            "Invalid username and/or password, please try again";
 
     // ---- ApplicationAware ----
 
@@ -109,11 +120,69 @@
         getApplication().put(DATABASE_KEY, database);
     }
 
+    // ---- SessionAware ----
+
+    /**
+     * <p>Field to store session context, or its proxy.</p>
+     */
+    private Map session;
+
+    /**
+     * <p>Store a new session context.</p>
+     *
+     * @param value A Map representing session state
+     */
+    public void setSession(Map value) {
+        session = value;
+    }
+
+    /**
+     * <p>Provide session context.</p>
+     *
+     * @return session context
+     */
+    public Map getSession() {
+        return session;
+    }
+
+    // ---- User property ----
+
+    /**
+     * <p>Provide reference to User object for authenticated user.</p>
+     *
+     * @return User object for authenticated user.
+     */
+    public User getUser() {
+        return (User) getSession().get(USER_KEY);
+    }
+
+    /**
+     * <p>Store new reference to User Object.</p>
+     *
+     * @param user User object for authenticated user
+     */
+    public void setUser(User user) {
+        getSession().put(USER_KEY, user);
+    }
+
     // ---- Database methods ----
 
     public User findUser(String username, String password)
             throws ExpiredPasswordException {
-        return getDatabase().findUser(username);
+
+        User user = getDatabase().findUser(username);
+
+        if ((user != null) && !user.getPassword().equals(password)) {
+            user = null;
+        }
+
+        if (user == null) {
+            addFieldError(PASSWORD_MISMATCH_FIELD,
+                    getText(ERROR_PASSWORD_MISMATCH));
+        }
+
+        return user;
+
     }
 
     public User createUser(String username, String password) throws Exception {
@@ -134,6 +203,12 @@
 
     public void saveUser() throws Exception {
         getDatabase().save();
+    }
+
+    // ---- Alias ----
+
+    public String cancel() {
+        return CANCEL;
     }
 
 }

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Register.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Register.java?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Register.java (original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/Register.java Thu Apr
 6 14:39:37 2006
@@ -14,7 +14,9 @@
             return Action.INPUT;
         }
 
-        createUser(getUsername(), getPassword());
+        user = createUser(getUsername(), getPassword());
+
+        setUser(user);
 
         saveUser();
 

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/xwork.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/xwork.xml?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/xwork.xml (original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/java/xwork.xml Thu Apr  6 14:39:37
2006
@@ -21,11 +21,21 @@
 
         <action name="Register" class="Register">
             <result name="input">/pages/Register.jsp</result>
-            <result type="chain">Menu</result>
+            <result type="redirect-action">Menu</result>
         </action>
 
         <action name="Menu" class="MailReaderSupport">
             <result>/pages/Menu.jsp</result>
+        </action>
+
+        <action name="Logout" class="Logout">
+            <result type="redirect-action">Welcome</result>
+        </action>
+
+        <action name="Login" class="Login">
+            <result name="input">/pages/Login.jsp</result>
+            <result name="cancel" type="redirect-action">Welcome</result>
+            <result type="redirect-action">Menu</result>
         </action>
 
     </package>

Added: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp?rev=392086&view=auto
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp (added)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp Thu
Apr  6 14:39:37 2006
@@ -0,0 +1,22 @@
+<%@ taglib uri="/webwork" prefix="ww" %>
+<html>
+<head>
+    <title>Login</title>
+</head>
+
+<body onLoad="self.focus();document.Logon.username.focus()">
+
+<ww:actionerror/>
+<ww:form method="POST" validate="true">
+    <ww:textfield label="UserName" name="username"/>
+
+    <ww:password label="Password" name="password" showPassword="true"/>
+
+    <ww:submit value="Save" name="Save"/>
+
+    <ww:submit action="Login!cancel" value="Cancel" name="Cancel"
+               onclick="form.onsubmit=null"/>
+</ww:form>
+
+</body>
+</html>

Propchange: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Login.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Menu.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Menu.jsp?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Menu.jsp (original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Menu.jsp Thu Apr
 6 14:39:37 2006
@@ -5,7 +5,7 @@
 </head>
 
 <body>
-<h3>Main Menu Options for <ww:property value="fullName"/></h3>
+<h3>Main Menu Options for <ww:property value="user.fullName"/></h3>
 <ul>
     <li><a href="<ww:url action="Register!input" />">
         Edit your registration profile

Modified: struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Welcome.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Welcome.jsp?rev=392086&r1=392085&r2=392086&view=diff
==============================================================================
--- struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Welcome.jsp (original)
+++ struts/sandbox/trunk/mailreader-course/action2/lab-2-3/src/webapp/pages/Welcome.jsp Thu
Apr  6 14:39:37 2006
@@ -9,7 +9,7 @@
 
 <ul>
     <li><a href="<ww:url action="Register!input"/>">Register with the MailReader</a></li>
-    <li><a href="<ww:url action="Missing"/>">Log on to the MailReader</a></li>
+    <li><a href="<ww:url action="Login!input"/>">Log on to the MailReader</a></li>
 </ul>
 
 <h3>Language Options</h3>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message