struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r388856 - in /struts/sandbox/trunk/action2: ./ apps/mailreader/src/java/ apps/mailreader/src/java/mailreader2/ apps/mailreader/src/webapp/pages/
Date Sat, 25 Mar 2006 23:16:11 GMT
Author: husted
Date: Sat Mar 25 15:16:07 2006
New Revision: 388856

URL: http://svn.apache.org/viewcvs?rev=388856&view=rev
Log:
Action2 Apps
* Mailreader - Work in progress
** Complete critical path 
** Still issues to resolve, but the core logic and workflow are in. 

Modified:
    struts/sandbox/trunk/action2/README.txt
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java
    struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml
    struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp
    struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp

Modified: struts/sandbox/trunk/action2/README.txt
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/README.txt?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/README.txt (original)
+++ struts/sandbox/trunk/action2/README.txt Sat Mar 25 15:16:07 2006
@@ -1,18 +1,17 @@
-This directory is a whiteboard area for working on new material 
-related to the adoption of WebWork2 as Action2. 
+This directory is a whiteboard area for working on new material related to
+the adoption of WebWork2 as Action2.
 
-Until a stable release of Action2 is available, this material 
-is being based on OS WebWork 2.2.
+While WebWork2/Action2 is passing through the incubator, this material is
+being based on OS WebWork 2.2.2.
 
-Note this area is intended for *NEW* material only. Existing 
-WebWork material will enter Apache Struts through the incubation 
-process. 
+Note this area is intended for *NEW* material only. Existing material must
+enter Apache Struts through the incubation process.
 
-At this time, the material is being built directly with IDEA, 
-and a standard build file is not yet available. 
+At this time, the material is being built directly with IDEA, and a standard
+build file is not yet available.
 
-For the time being, the dependencies required to build this
-material may be downloaded here: 
+For the time being, the dependencies required to build this material may be
+downloaded here:
 
 * http://people.apache.org/~husted/sandbox-action2-lib.zip
 
@@ -20,5 +19,173 @@
 
 * http://www.StrutsUniversity.org/Application+Use+Cases
 
-###
+----------------------------------------------------------------------------
 
+APPS
+
+Under the apps folder, two applications are now being constructed
+
+ * Cookbook, and
+ * Mailreader
+
+The goal of the Cookbook is to combine the WebWork 2.2.2  Showcase with the
+Struts 1.3 Examples and the Struts 1.3 Cookbook.
+
+The Cookbook demonstrates working code and provides links to display the
+code for each example.
+
+The goal of the Mailreader is to provide a simple application that
+demonstrates best practices.
+
+The Mailreader is a simple parent/child workflow, where visitors can register
+with the application and the create child records related to the user's
+master account.
+
+Other new applications may include the iBATIS JPetstore example,
+which was based on Struts Action 1.
+
+Other WebWork example applications, like the shopping cart, could also be
+kept here.
+
+----------------------------------------------------------------------------
+
+STATUS - COOKBOOK
+
+* Several examples have been added.
+
+* The "Select" example could be streamlined to use one example of each
+Select control.
+
+* Other examples can be added at will.
+
+----------------------------------------------------------------------------
+
+STATUS - MAILREADER
+
+* Work in progress.
+
+----
+
+Welcome
+
+Nominal
++ Logon - Cancel
++ Register - Cancel
+
+Issues
+* Powered image not displaying.
+
+----
+
+Logon
+
+Nominal
++ Cancel
++ Reset
+- Submit (invalid) (*)
++ Submit (incorrect)
++ Submit
+
+Issues
+* Submit (invalid)
+** The "errors.password.mismatch" is not being resolved as message
+
+----
+
+Registraton Edit
+
+Nominal
++ Cancel
++ Reset
+- Submit (no change) (*)
+- Submit (change) (*)
+- Submit (invalid change) (*)
+
+Issues
+* Submit - no change
+** Password is displayed in plain text
+** Is there a WW way to set the focus?
+* Edit - Submit (change)
+** Password doesn't change when edited
+** Password Confirmation message not displayed
+* Edit = Submit (invalid change) (*)
+** When client-side validation is enabled, messages stack up on multiple invalid submits.
Sever-side only OK.
+*** This doesn't happen with Logon page
+
+----
+
+Subscription Edit
+
+Nominal
++ Cancel (*)
++ Save (no changes)
++ Save (changes)
+
+Issues
+* Cancel
+** Goes to MainMenu rather than (back to) Registration
+
+----
+
+Subscription Delete
+
+Norminal
+  Cancel
+  Confirm
+
+----
+
+Subscription Add
+
+----
+
+Logoff
+
+Nominal
+* Logoff - Refresh
+* Logoff - Skip to Registeration page (*)
+
+Issues
+* Skip to Registration - Displays blank Main Menu; Edit defaults to Create
+
+----
+
+Registration Create
+
+Nominal
++ Cancel
++ Reset
+- Submit (no data)  (*)
++ Submit (invalid data)
++ Submit (data)
+- Submit (duplicate data) (*)
+
+Issues (*)
+* Submit
+** Not parsing message variables: {0} in the range {1}
+* Submit (duplidate data)
+** Fails silently for duplicate user name
+** Password Confirmation message not displayed
+* Submit (invalid data)
+** When client-side validation is enabled, messages stack up on multiple invalid submits.
Sever-side only OK.
+
+----
+
+Locale change
+* TODO
+
+----
+
+Tour
+* TODO
+
+----
+
+Error
+* Need to log and present unexpected exceptions
+
+----
+
+
+
+====

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java
(original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.java
Sat Mar 25 15:16:07 2006
@@ -18,6 +18,7 @@
 
 package mailreader2;
 
+import com.opensymphony.util.BeanUtils;
 import com.opensymphony.webwork.interceptor.ApplicationAware;
 import com.opensymphony.webwork.interceptor.SessionAware;
 import com.opensymphony.xwork.ActionSupport;
@@ -27,6 +28,8 @@
 import org.apache.struts.apps.mailreader.dao.Subscription;
 import org.apache.struts.apps.mailreader.dao.User;
 import org.apache.struts.apps.mailreader.dao.UserDatabase;
+import org.apache.struts.apps.mailreader.dao.impl.memory.MemorySubscription;
+import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUser;
 
 import java.util.Map;
 
@@ -231,6 +234,49 @@
         }
     }
 
+    public void createInputUser() {
+        User user = new MemoryUser(null, null);
+        setUser(user);
+    }
+
+    /**
+     * <p> Verify input for creating a new user, create the user, and process the login.
</p>
+     *
+     * @return A new User and empty Errors if create succeeds, or null and Errors if create
fails
+     */
+    public User createUser(String username, String password) {
+
+        UserDatabase database = getDatabase();
+        User user;
+
+        try {
+
+            user = findUser(username, password);
+        }
+
+        catch (ExpiredPasswordException e) {
+            user = getUser(); // Just so that it is not null
+        }
+
+        if (user != null) {
+            this.addFieldError("username", "error.username.unique");
+            return null;
+        }
+
+        return database.createUser(username);
+    }
+
+    // Since user.username is immutable, we have to use some local properties
+    public void copyUser(String _username, String _password) {
+        User input = getUser();
+        input.setPassword(_password);
+        User user = createUser(_username, _password);
+        if (null != user) {
+            BeanUtils.setValues(user, input, null);
+            setUser(user);
+        }
+    }
+
     // ---- Subscription property ----
 
     /**
@@ -251,12 +297,12 @@
      *
      * @return The matching Subscription or null
      */
-    public Subscription findSubscription() {
+    public Subscription findSubscription(String host) {
 
         Subscription subscription;
 
         try {
-            subscription = getUser().findSubscription(getHost());
+            subscription = getUser().findSubscription(host);
         }
         catch (NullPointerException e) {
             subscription = null;
@@ -265,11 +311,45 @@
         return subscription;
     }
 
+    public Subscription findSubscription() {
+
+        return findSubscription(getHost());
+    }
+
+    public void createInputSubscription() {
+        Subscription sub = new MemorySubscription(getUser(), null);
+        setSubscription(sub);
+        setHost(sub.getHost());
+    }
+
+    public Subscription createSubscription(String host) {
+
+        Subscription sub;
+
+        sub = findSubscription(host);
+
+        if (null != sub) {
+            this.addFieldError("host", "error.host.unique");
+            return null;
+        }
+
+        return getUser().createSubscription(host);
+    }
+
+    public void copySubscription(String host) {
+        Subscription input = getSubscription();
+        Subscription sub = createSubscription(host);
+        if (null != sub) {
+            BeanUtils.setValues(sub, input, null);
+            setSubscription(sub);
+            setHost(sub.getHost());
+        }
+    }
+
     public void removeSubscription() throws Exception {
         getUser().removeSubscription(getSubscription());
         getSession().remove(Constants.SUBSCRIPTION_KEY);
     }
-
 
     public String getSubscriptionHost() {
         Subscription sub = getSubscription();

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Registration.java Sat
Mar 25 15:16:07 2006
@@ -1,10 +1,6 @@
 package mailreader2;
 
-import com.opensymphony.util.BeanUtils;
-import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
 import org.apache.struts.apps.mailreader.dao.User;
-import org.apache.struts.apps.mailreader.dao.UserDatabase;
-import org.apache.struts.apps.mailreader.dao.impl.memory.MemoryUser;
 
 
 /**
@@ -14,37 +10,6 @@
  */
 public final class Registration extends MailreaderSupport {
 
-    // ---- Private Methods ----
-
-    /**
-     * <p> Verify input for creating a new user, create the user, and process the login.
</p>
-     *
-     * @return A new User and empty Errors if create succeeds, or null and Errors if create
fails
-     */
-    private User createUser(String username, String password) {
-
-        UserDatabase database = getDatabase();
-        User user;
-
-        try {
-
-            user = findUser(username, password);
-        }
-
-        catch (ExpiredPasswordException e) {
-            user = getUser(); // Just so that it is not null
-        }
-
-        if (user != null) {
-            this.addFieldError("username", "error.username.unique");
-            return null;
-        }
-
-        return database.createUser(username);
-    }
-
-    // ----- Public Methods ----
-
     private boolean isCreating() {
         User user = getUser();
         return (null == user) || (null == user.getDatabase());
@@ -60,8 +25,7 @@
     public String input() throws Exception {
 
         if (isCreating()) {
-            User user = new MemoryUser(null, null);
-            setUser(user);
+            createInputUser();
             setTask(Constants.CREATE);
         } else {
             setTask(Constants.EDIT);
@@ -86,14 +50,8 @@
         boolean creating = Constants.CREATE.equals(getTask());
         creating = creating && isCreating(); // trust but verify
 
-        User user;
         if (creating) {
-            User input = getUser();
-            // Since user.username is immutable, we have to use some local properties
-            user = createUser(getUsername(), getPassword());
-            input.setPassword(getPassword());
-            BeanUtils.setValues(user, input, null);
-            setUser(user);
+            copyUser(getUsername(), getPassword());
         }
 
         saveUser();

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription.java Sat
Mar 25 15:16:07 2006
@@ -34,20 +34,12 @@
     }
 
     public String input() {
-
+        createInputSubscription();
         setTask(Constants.CREATE);
         return INPUT;
     }
 
-    public String delete() {
-
-        setTask(Constants.DELETE);
-        return INPUT;
-    }
-
-    public String edit() {
-
-        setTask(Constants.EDIT);
+    public String find() {
 
         org.apache.struts.apps.mailreader.dao.Subscription
                 sub = findSubscription();
@@ -59,12 +51,29 @@
         setSubscription(sub);
 
         return INPUT;
+
+    }
+
+    public String delete() {
+
+        setTask(Constants.DELETE);
+        return find();
+    }
+
+    public String edit() {
+
+        setTask(Constants.EDIT);
+        return find();
     }
 
     public String execute() throws Exception {
 
         if (Constants.DELETE.equals(getTask())) {
             removeSubscription();
+        }
+
+        if (Constants.CREATE.equals(getTask())) {
+            copySubscription(getHost());
         }
 
         saveUser();

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml Sat Mar 25 15:16:07 2006
@@ -7,18 +7,6 @@
 
         <!-- default-action-ref name="Welcome"/ -->
 
-        <global-results>
-            <result name="error">/pages/Error.jsp</result>
-        </global-results>
-
-        <global-exception-mappings>
-
-            <exception-mapping
-                    result="error"
-                    exception="java.lang.Exception"/>
-
-        </global-exception-mappings>
-
         <action name="Welcome">
             <result>/pages/Welcome.jsp</result>
         </action>

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Registration.jsp Sat Mar
25 15:16:07 2006
@@ -9,6 +9,7 @@
     <a2:if test="task=='Edit'">
         <title><a2:text name="registration.title.edit"/></title>
     </a2:if>
+    <link href="<a2:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/>
 </head>
 
 <body>

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp?rev=388856&r1=388855&r2=388856&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Subscription.jsp Sat Mar
25 15:16:07 2006
@@ -12,6 +12,7 @@
     <ui:if test="task=='Delete'">
         <title><ui:text name="subscription.title.delete"/></title>
     </ui:if>
+    <link href="<ui:url value="/css/mailreader.css"/>" rel="stylesheet" type="text/css"/>
 </head>
 
 <body>
@@ -20,31 +21,30 @@
     <ui:label label="%{getText('prompt.username')}" name="user.username"/>
 
     <ui:if test="task == 'Create'">
-        <ui:textfield label="%{getText('prompt.mailHostname')}" name="subscription.host"/>
+        <ui:textfield label="%{getText('prompt.mailHostname')}" name="host"/>
     </ui:if>
     <ui:else>
         <ui:label label="%{getText('prompt.mailHostname')}" name="host"/>
         <ui:hidden name="host"/>
     </ui:else>
 
-    <ui:textfield label="%{getText('prompt.mailUsername')}" name="subscription.username"/>
-
-    <ui:textfield label="%{getText('prompt.mailPassword')}" name="subscription.password"/>
-
-    <ui:select label="%{getText('prompt.mailServerType')}" name="subscription.type"
-               list="types"/>
-
-    <ui:checkbox label="%{getText('prompt.autoConnect')}" name="subscription.autoConnect"/>
-
     <ui:if test="task == 'Delete'">
+        <ui:label label="%{getText('prompt.mailUsername')}" name="subscription.username"/>
+        <ui:label label="%{getText('prompt.mailPassword')}" name="subscription.password"/>
+        <ui:label label="%{getText('prompt.mailServerType')}" name="subscription.type"/>
+        <ui:label label="%{getText('prompt.autoConnect')}" name="subscription.autoConnect"/>
         <ui:submit value="%{getText('button.confirm')}"/>
-        <ui:reset value="%{getText('button.reset')}"/>
     </ui:if>
     <ui:else>
+        <ui:textfield label="%{getText('prompt.mailUsername')}" name="subscription.username"/>
+        <ui:textfield label="%{getText('prompt.mailPassword')}" name="subscription.password"/>
+        <ui:select label="%{getText('prompt.mailServerType')}" name="subscription.type"
list="types"/>
+        <ui:checkbox label="%{getText('prompt.autoConnect')}" name="subscription.autoConnect"/>
         <ui:submit value="%{getText('button.save')}"/>
+        <ui:reset value="%{getText('button.reset')}"/>
     </ui:else>
 
-    <ui:submit action="MainMenu" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/>
+    <ui:submit action="Registration!input" value="%{getText('button.cancel')}" onclick="form.onsubmit=null"/>
 </ui:form>
 
 <jsp:include page="Footer.jsp"/>



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


Mime
View raw message