struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r389507 - in /struts/sandbox/trunk/action2: ./ apps/mailreader/src/java/ apps/mailreader/src/java/mailreader2/ apps/mailreader/src/webapp/pages/
Date Tue, 28 Mar 2006 14:22:39 GMT
Author: husted
Date: Tue Mar 28 06:22:02 2006
New Revision: 389507

URL: http://svn.apache.org/viewcvs?rev=389507&view=rev
Log:
Action2 Apps
* Mailreader - work in progess
** Display exception message and stack trace on unexpected error page 
** Fix duplicate user issue
* Down to "double submit" and then the Tour!


Modified:
    struts/sandbox/trunk/action2/README.txt
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java
    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/Error.jsp
    struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp
    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=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/README.txt (original)
+++ struts/sandbox/trunk/action2/README.txt Tue Mar 28 06:22:02 2006
@@ -58,6 +58,20 @@
 
 * Other examples can be added at will.
 
+Example idea jar
+
+* See http://www.niallp.pwp.blueyonder.co.uk/strutsvalidatorextends.html
+for some validation use cases.
+
+* How do we set checkboxes false (on uncheck)?
+** http://forums.opensymphony.com/thread.jspa?threadID=23601&tstart=0
+
+* How to set the focus on a form field?
+** http://forums.opensymphony.com/thread.jspa?threadID=23777&tstart=0
+
+* Display an unexpected exception on an error page. 
+
+
 ----------------------------------------------------------------------------
 
 STATUS - MAILREADER
@@ -79,14 +93,10 @@
 Nominal
 + Cancel
 + Reset
-- Submit (invalid) (*)
+- Submit (invalid) 
 + Submit (incorrect)
 + Submit
 
-Issues
-* Submit (invalid)
-** The "errors.password.mismatch" is not being resolved as message
-
 ----
 
 Registraton Edit
@@ -94,20 +104,14 @@
 Nominal
 + Cancel
 + Reset
-- Submit (no change) (*)
-- Submit (change) (*)
-- Submit (invalid change) (*)
++ 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? (Asked in forum)
-* 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
+* When client-side validation is enabled, messages stack up on multiple invalid submits.
Sever-side only OK.
+*** This doesn't happen with Logon page, only Registration and Subscription (!?)(
+*** Asked on forum - http://forums.opensymphony.com/thread.jspa?threadID=23871&tstart=0
 
 ----
 
@@ -150,17 +154,11 @@
 + Cancel
 + Reset
 + Submit (no data)
-+ Submit (invalid data) (*)
++ Submit (invalid data)
 + Submit (data)
-- Submit (duplicate data) (*)
++ Submit (duplicate data)
   Double submit
 
-Issues (*)
-* Submit (invalid data)
-** When client-side validation is enabled, messages stack up on multiple invalid submits.
Sever-side only OK.
-* Submit (duplidate data)
-** Fails silently for duplicate user name
-
 ----
 
 Locale change
@@ -175,7 +173,20 @@
 ----
 
 Error
-* Need to log and present unexpected exceptions
++ Need to log and present unexpected exceptions
+
+
+Issue 
+* It would be nice to omit the message markup if there is not message. 
+** http://forums.opensymphony.com/thread.jspa?threadID=7480&messageID=16618#16618
+
+Things that didn't work:
+
+<saf:if test=" %(exception.message}?exists">
+
+<saf:if test=" %this.exception.message?exists">
+
+<saf:if test=" #(exception.message} != null ">
+
 
-----
 ====

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java?rev=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java
(original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/ApplicationListener.java
Tue Mar 28 06:22:02 2006
@@ -25,18 +25,14 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.*;
 
 /**
  * <p><code>ServletContextListener</code> that initializes and finalizes
the
  * persistent storage of User and Subscription information for the Struts
  * Demonstration Application, using an in-memory database backed by an XML
  * file.</p>
- *
+ * <p/>
  * <p><strong>IMPLEMENTATION WARNING</strong> - If this web application
is run
  * from a WAR file, or in another environment where reading and writing of the
  * web application resource is impossible, the initial contents will be copied
@@ -44,15 +40,15 @@
  * container.  This is for demonstration purposes only - you should
  * <strong>NOT</strong> assume that files written here will survive a restart
  * of your servlet container.</p>
- *
+ * <p/>
  * <p>This class was borrowed from the Shale Mailreader. Changes were:</p>
- *
+ * <p/>
  * <ul>
- *
+ * <p/>
  * <li>Path to database.xml (under classes here). </li>
- *
+ * <p/>
  * <li>Class to store protocol list (an array here). </li>
- *
+ * <p/>
  * </ul>
  */
 

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java?rev=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Logon.java Tue Mar 28
06:22:02 2006
@@ -18,7 +18,6 @@
 
 package mailreader2;
 
-import org.apache.struts.apps.mailreader.dao.ExpiredPasswordException;
 import org.apache.struts.apps.mailreader.dao.User;
 
 /**
@@ -31,7 +30,7 @@
      * the database. If credentials are not valid, or database has
      * disappeared, post error messages and forward to input. </p>
      */
-    public String execute() throws ExpiredPasswordException {
+    public String execute() throws Exception {
 
         User user = findUser(getUsername(), getPassword());
 

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=389507&r1=389506&r2=389507&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
Tue Mar 28 06:22:02 2006
@@ -35,7 +35,7 @@
 
 /**
  * <p> Base Action for MailreaderSupport application. </p>
- *
+ * <p/>
  * <p> Note that this class does NOT implement model driven because of the way
  * the pre-existing model is designed. The MailReader DAO includes immutable
  * fields that can only be set on construction, and some objects do not have a
@@ -56,7 +56,7 @@
 
     /**
      * <p>Field to store application context or its proxy.</p>
-     *
+     * <p/>
      * <p>The application context lasts for the life of the application. A
      * reference to the database is stored in the application context at
      * startup.</p>
@@ -108,7 +108,7 @@
 
     /**
      * <p>Field to store workflow task.</p>
-     *
+     * <p/>
      * <p>The Task is used to track the state of the CRUD workflows. It can be
      * set to Constant.CREATE, Constant.EDIT, or Constant.DELETE as
      * needed.</p>
@@ -138,7 +138,7 @@
 
     /**
      * <p>Field to store Subscription host.</p>
-     *
+     * <p/>
      * <p> The host is an immutable property of the Subscrtion DAP object, so
      * we need to store it locally until we are ready to create the
      * Subscription. </p>
@@ -167,7 +167,7 @@
 
     /**
      * <p>Field to store User password property.</p>
-     *
+     * <p/>
      * <p>The User DAO object password proerty is immutable, so we store it
      * locally until we are ready to create the object.</p>
      */
@@ -196,7 +196,7 @@
 
     /**
      * <p>Field to store the User password confirmation.</p>
-     *
+     * <p/>
      * <p>When a User object is created, we ask the client to enter the
      * password twice, to help ensure the password is being typed
      * correctly.</p>
@@ -226,7 +226,7 @@
 
     /**
      * <p>Field to store User username.</p>
-     *
+     * <p/>
      * <p>The User DAO object password proerty is immutable, so we store it
      * locally until we are ready to create the object.</p>
      */
@@ -384,7 +384,7 @@
     /**
      * <p>Use the current User object to create a new User object, and make
      * the new User object the authenticated user.</p>
-     *
+     * <p/>
      * <p>The "current" User object is usually a temporary object being used
      * to capture input.</p>
      *
@@ -443,7 +443,7 @@
 
     /**
      * <p>Obtain uSER Subscription for the local Host property.</p>
-     *
+     * <p/>
      * <p>Usually, the host property will be set from the client request,
      * because it was embedded in a link to the Subcription action.
      *
@@ -488,7 +488,7 @@
     /**
      * <p>Create a new Subscription from the current Subscription object,
      * making the new Subscription the current Subscription. </p>
-     *
+     * <p/>
      * <p>Usually, the "current" Subscription is a temporary object being used
      * to capture input values.</p>
      *

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=389507&r1=389506&r2=389507&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 Tue
Mar 28 06:22:02 2006
@@ -41,7 +41,7 @@
 
     /**
      * <p> Insert or update a User object to the persistent store. </p>
-     *
+     * <p/>
      * <p> If a User is not logged in, then a new User is created and
      * automatically logged in. Otherwise, the existing User is updated. </p>
      *
@@ -55,18 +55,28 @@
         creating = creating && isCreating(); // trust but verify
 
         if (creating) {
+
+            User user = findUser(getUsername(), getPassword());
+            boolean haveUser = (user != null);
+
+            if (haveUser) {
+                addActionError(getText("error.username.unique"));
+                return INPUT;
+            }
+
             copyUser(getUsername(), getPassword());
-        }
-        else {
+
+        } else {
+
             // FIXME: Any way to call the RegisrationSave validators from here?
-            String pw = getPassword();
-            if (pw!=null) {
-                String pw2 = getPassword2();
-                boolean matches = ((null!=pw2) && (pw2.equals(pw)));
+            String newPassword = getPassword();
+            if (newPassword != null) {
+                String confirmPassword = getPassword2();
+                boolean matches = ((null != confirmPassword)
+                        && (confirmPassword.equals(newPassword)));
                 if (matches) {
-                    getUser().setPassword(pw);
-                }
-                else {
+                    getUser().setPassword(newPassword);
+                } else {
                     addActionError(getText("error.password.match"));
                     return INPUT;
                 }

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=389507&r1=389506&r2=389507&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 Tue
Mar 28 06:22:02 2006
@@ -54,7 +54,7 @@
 
     /**
      * <p>Load User Subscription for the local Host property.</p>
-     *
+     * <p/>
      * <p>Usually, the Host is being set from the request by a link to an Edit
      * or Delete task.</p>
      *

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=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml Tue Mar 28 06:22:02 2006
@@ -68,7 +68,7 @@
             <result name="input">/pages/Subscription.jsp</result>
             <result type="redirect-action">Registration!input</result>
         </action>
-        
+
         <action name="Logoff" class="mailreader2.Logoff">
             <result type="redirect-action">Welcome</result>
         </action>

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Error.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Error.jsp?rev=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Error.jsp (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Error.jsp Tue Mar 28 06:22:02
2006
@@ -1,3 +1,5 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib uri="/webwork" prefix="saf" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -6,7 +8,29 @@
 </head>
 
 <body>
-<h3>An unexpected error has occured</h3>
+<h2>An unexpected error has occured</h2>
+
+<p>
+    Please report this error to your system administrator
+    or appropriate technical suppoert personnel.
+    Thank you for your cooperation.
+</p>
+
+<hr/>
+
+<h3>Error Message</h3>
+
+<p>
+    <saf:property value="%{exception.message}"/>
+</p>
+
+<hr/>
+
+<h3>Technical Details</h3>
+
+<p>
+    <saf:property value="%{exceptionStack}"/>
+</p>
 
 <jsp:include page="Footer.jsp"/>
 

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp?rev=389507&r1=389506&r2=389507&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/Logon.jsp Tue Mar 28 06:22:02
2006
@@ -9,9 +9,9 @@
           type="text/css"/>
 </head>
 
-<body onLoad="self.focus();document.Logon.username.focus()"  >
+<body onLoad="self.focus();document.Logon.username.focus()">
 
-<saf:actionerror />
+<saf:actionerror/>
 <saf:form method="POST" validate="true">
     <saf:textfield label="%{getText('username')}" name="username"/>
 
@@ -22,7 +22,7 @@
     <saf:reset value="%{getText('button.reset')}"/>
 
     <saf:submit action="Welcome" value="%{getText('button.cancel')}"
-               onclick="form.onsubmit=null"/>
+                onclick="form.onsubmit=null"/>
 </saf:form>
 
 <jsp:include page="Footer.jsp"/>

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=389507&r1=389506&r2=389507&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 Tue Mar
28 06:22:02 2006
@@ -14,9 +14,9 @@
           type="text/css"/>
 </head>
 
-<body onLoad="self.focus();document.Registration.username.focus()"  >
+<body onLoad="self.focus();document.Registration.username.focus()">
 
-<saf:actionerror />
+<saf:actionerror/>
 <saf:form method="POST" validate="false">
     <saf:hidden name="task"/>
     <saf:if test="task == 'Create'">

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=389507&r1=389506&r2=389507&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 Tue Mar
28 06:22:02 2006
@@ -17,9 +17,9 @@
           type="text/css"/>
 </head>
 
-<body onLoad="self.focus();document.Subscription.username.focus()"  >
+<body onLoad="self.focus();document.Subscription.username.focus()">
 
-<saf:actionerror />
+<saf:actionerror/>
 <saf:form method="POST" action="SubscriptionSave" validate="false">
     <saf:hidden name="task"/>
     <saf:label label="%{getText('username')}" name="user.username"/>



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


Mime
View raw message