struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hus...@apache.org
Subject svn commit: r391020 - in /struts/sandbox/trunk/action2/apps/mailreader/src: java/ java/mailreader2/ webapp/pages/
Date Mon, 03 Apr 2006 11:50:25 GMT
Author: husted
Date: Mon Apr  3 04:50:24 2006
New Revision: 391020

URL: http://svn.apache.org/viewcvs?rev=391020&view=rev
Log:
MailReader 
* Correct various typos pointed out by Claus Ibsen
* Refactor interceptor stacks
* Remove unused Constants

Added:
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml
  (with props)
Modified:
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java
    struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/MailreaderSupport.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/tour.html

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java?rev=391020&r1=391019&r2=391020&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Constants.java Mon Apr
 3 04:50:24 2006
@@ -52,17 +52,6 @@
     public static final String EDIT = "Edit";
 
     /**
-     * <p> The token representing a "failure" result for this application.
-     * </p>
-     */
-    public static final String FAILURE = "Failure";
-
-    /**
-     * <p> The token representing a "logon" result for this application. </p>
-     */
-    public static final String LOGON = "Logon";
-
-    /**
      * <p> The package name for this application. </p>
      */
     public static final String PACKAGE = "org.apache.struts.apps.mailreader";
@@ -74,17 +63,17 @@
     public static final String SUBSCRIPTION_KEY = "subscription";
 
     /**
-     * <p> The token representing a "success" result for this application.
-     * </p>
-     */
-    public static final String SUCCESS = "Success";
-
-    /**
      * <p> The session scope attribute under which the User object for the
      * currently logged in user is stored. </p>
      */
     public static final String USER_KEY = "user";
 
+    /**
+     * <p>The token representing the "Host" property.
+     */
+    public static final String HOST = "host";
+
+    
     // ---- Error Messages ----
 
     /**

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=391020&r1=391019&r2=391020&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
Mon Apr  3 04:50:24 2006
@@ -507,7 +507,8 @@
         sub = findSubscription(host);
 
         if (null != sub) {
-            this.addFieldError("host", "error.host.unique");
+            // FIXME - localization - "error.host.unique")
+            addFieldError(Constants.HOST,"That hostname is already defined");
             return null;
         }
 
@@ -535,10 +536,8 @@
 
     /**
      * <p>Delete the current Subscription object from the database.</p>
-     *
-     * @throws Exception
      */
-    public void removeSubscription() throws Exception {
+    public void removeSubscription()  {
         getUser().removeSubscription(getSubscription());
         getSession().remove(Constants.SUBSCRIPTION_KEY);
     }

Added: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml?rev=391020&view=auto
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml
(added)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml
Mon Apr  3 04:50:24 2006
@@ -0,0 +1,11 @@
+<!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="host">
+        <field-validator type="requiredstring">
+            <message key="error.host.required"/>
+        </field-validator>
+    </field>
+
+</validators>

Propchange: struts/sandbox/trunk/action2/apps/mailreader/src/java/mailreader2/Subscription-validation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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=391020&r1=391019&r2=391020&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 Mon
Apr  3 04:50:24 2006
@@ -116,6 +116,8 @@
             copySubscription(getHost());
         }
 
+        if (hasErrors()) return INPUT;
+        
         saveUser();
         return SUCCESS;
     }

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=391020&r1=391019&r2=391020&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/java/xwork.xml Mon Apr  3 04:50:24 2006
@@ -7,16 +7,31 @@
 
         <interceptors>
 
-            <interceptor name="authenticate" class="mailreader2.AuthenticationInterceptor"/>
+            <interceptor name="authentication"
+                         class="mailreader2.AuthenticationInterceptor"/>
 
-            <interceptor-stack name="access" >
-                <interceptor-ref name="authenticate" />
+            <interceptor-stack name="user" >
+                <interceptor-ref name="authentication" />
                 <interceptor-ref name="defaultStack"/>
             </interceptor-stack>
 
+            <interceptor-stack name="user-submit" >
+                <interceptor-ref name="token-session" />
+                <interceptor-ref name="user"/>
+            </interceptor-stack>
+
+            <interceptor-stack name="guest" >
+                <interceptor-ref name="defaultStack"/>
+            </interceptor-stack>
+
+            <interceptor-stack name="guest-submit" >
+                <interceptor-ref name="token-session" />
+                <interceptor-ref name="guest"/>
+            </interceptor-stack>
+
         </interceptors>
 
-        <default-interceptor-ref name="access"/>
+        <default-interceptor-ref name="user"/>
         
         <default-action-ref name="Welcome"/>
 
@@ -34,7 +49,7 @@
 
         <action name="Welcome" class="mailreader2.Welcome">
             <result>/pages/Welcome.jsp</result>
-            <interceptor-ref name="defaultStack"/>
+            <interceptor-ref name="guest"/>
         </action>
 
         <action name="Logon" class="mailreader2.Logon">
@@ -45,7 +60,7 @@
             <exception-mapping
                     exception="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException"
                     result="expired"/>
-            <interceptor-ref name="defaultStack"/>
+            <interceptor-ref name="guest"/>
         </action>
 
         <action name="ChangePassword">
@@ -59,14 +74,13 @@
         <action name="Registration" class="mailreader2.Registration">
             <result name="input">/pages/Registration.jsp</result>
             <result type="redirect-action">MainMenu</result>
-            <interceptor-ref name="defaultStack"/>
+            <interceptor-ref name="guest"/>
         </action>
 
         <action name="RegistrationSave" class="mailreader2.RegistrationSave">
             <result name="input">/pages/Registration.jsp</result>
             <result type="redirect-action">MainMenu</result>
-            <interceptor-ref name="token-session" />
-            <interceptor-ref name="defaultStack"/>
+            <interceptor-ref name="guest-submit" />
         </action>
 
         <action name="Subscription" class="mailreader2.Subscription">
@@ -77,8 +91,7 @@
         <action name="SubscriptionSave" class="mailreader2.SubscriptionSave">
             <result name="input">/pages/Subscription.jsp</result>
             <result type="redirect-action">Registration!input</result>
-            <interceptor-ref name="token-session" />
-            <interceptor-ref name="access"/>
+            <interceptor-ref name="user-submit" />
         </action>
 
         <action name="Logoff" class="mailreader2.Logoff">
@@ -87,7 +100,7 @@
 
         <action name="Tour">
             <result>/pages/tour.html</result>
-            <interceptor-ref name="defaultStack"/>
+            <interceptor-ref name="guest"/>
         </action>
 
     </package>

Modified: struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/tour.html
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/tour.html?rev=391020&r1=391019&r2=391020&view=diff
==============================================================================
--- struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/tour.html (original)
+++ struts/sandbox/trunk/action2/apps/mailreader/src/webapp/pages/tour.html Mon Apr  3 04:50:24
2006
@@ -95,7 +95,7 @@
     <li>
         <a href="#Registration.jsp">Registration page</a>
         <ul>
-            <li><a href="iterator">iterator</a></li>
+            <li><a href="#iterator">iterator</a></li>
         </ul>
     </li>
 </ul>
@@ -299,7 +299,7 @@
 </p>
 <hr/>
 <h5>A simple "forward thru" action element</h5>
-<pre><code>&lt;action name="<strong>>Welcome</strong>">
+<pre><code>&lt;action name="<strong>Welcome</strong>">
   &lt;result><strong>/pages/Welcome.jsp</strong>&lt;/result>
 &lt;/action></code></pre>
 <hr/>
@@ -320,8 +320,8 @@
 <hr/>
 <h5>The Welcome action element</h5>
 <pre><code>&lt;action name="Welcome" <b>class="mailreader2.Welcome"</b>>
-    <strong>&lt;interceptor-ref name="defaultStack"/></strong>
     &lt;result>/pages/Welcome.jsp&lt;/result>
+    <strong>&lt;interceptor-ref name="guest"/></strong>
     &lt;/action></code></pre>
 <hr/>
 
@@ -1082,12 +1082,11 @@
 <pre><code>private Map session;
 public Map <strong>getSession()</strong> {
   return session;
-}
-<hr />
 
 public void <strong>setSession(Map value)</strong> {
   session = value;
 }</code></pre>
+<hr />
 
 <p>
     To look at the MailreaderSupport class, you would think the Session property is a plain-old
Map.
@@ -1219,7 +1218,7 @@
   &lt;<strong>exception-mapping</strong>
     exception="org.apache.struts.apps.mailreader.dao.ExpiredPasswordException"
   result="<strong>expired</strong>"/>
-  &lt;interceptor-ref name="<strong>defaultStack</strong>"/>
+  &lt;interceptor-ref name="<strong>guest</strong>"/>
 &lt;/action></code></pre>
 <hr/>
 
@@ -1363,33 +1362,40 @@
 </p>
 
 <p>
-    The MailReader defines two custom Interceptor stacks, <strong>access</strong>
-    and <strong>submit</strong>, and sets the default-interceptor to "access".
+    The MailReader defines four custom Interceptor stacks: "user", "user-submit",
+    "guest", and "guest-submit".
 </p>
 
 <hr/>
 <h5>xwork.xml interceptors</h5>
 <pre><code>&lt;interceptors>
-  &lt;interceptor name="<strong>authenticate</strong>" class="mailreader2.AuthenticationInterceptor"/>
-  &lt;interceptor-stack name="<strong>access</strong>" >
-    &lt;interceptor-ref name="authenticate" />
-    &lt;interceptor-ref name="defaultStack"/>
+  &lt;interceptor name="<strong>authentication</strong>"
+               class="mailreader2.AuthenticationInterceptor"/>
+  &lt;interceptor-stack name="<strong>user</strong>" >
+      &lt;interceptor-ref name="authentication" />
+      &lt;interceptor-ref name="defaultStack"/>
   &lt;/interceptor-stack>
-  &lt;interceptor-stack name="<strong>submit</strong>">
-    &lt;interceptor-ref name="token-session" />
-    &lt;interceptor-ref name="<strong>access</strong>" />
+  &lt;interceptor-stack name="<strong>user-submit</strong>" >
+      &lt;interceptor-ref name="token-session" />
+      &lt;interceptor-ref name="user"/>
+  &lt;/interceptor-stack>
+  &lt;interceptor-stack name="<strong>guest</strong>" >
+      &lt;interceptor-ref name="defaultStack"/>
+  &lt;/interceptor-stack>
+  &lt;interceptor-stack name="<strong>guest-submit</strong>" >
+      &lt;interceptor-ref name="token-session" />
+      &lt;interceptor-ref name="guest"/>
   &lt;/interceptor-stack>
 &lt;/interceptors>
-
-&lt;<strong>default-interceptor-ref</strong> name="access"/></code></pre>
+&lt;<strong>default-interceptor-ref</strong> name="user"/></code></pre>
 <hr/>
 
 <p>
-    The "submit" stack is to be used with actions that post forms.
-    It includes the "token-session" Interceptor which guards against double-submits,
-    and then goes to include the "access" interceptor stack.
-    The "access" stack includes the authenticate Interceptor,
-    and then falls back to the standard "defaultStack".
+    The <strong>user</strong> stacks require that the client be authenticated,
+    in other words that a User object is present in the session.
+    The actions using a <strong>guest</strong> stack can be accessed by any client.
+    The <strong>-submit</strong> versions of each can be used with actions
+    with forms, to guard against double submits.
 </p>
 
 <h5>Double Submits</h5>
@@ -1534,7 +1540,7 @@
 </p>
 
 <hr />
-<h5>MainMenu.jsp - head element</h5>
+<h5>Registration.jsp - head element</h5>
 <pre><code>&lt;head>
   &lt;saf:if test="<strong>task=='Create'</strong>">
     &lt;title>&lt;saf:text name="registration.title.create"/>&lt;/title>
@@ -1607,7 +1613,7 @@
     So to display each subscription, we have to reach into the user object,
     and loop through the members of the subscription collection.
     Using the iterator tag, you can code it the way it sounds.
- /p>
+ </p>
 
 <hr/>
 <h5>Using iterator to list the Subscriptions</h5>
@@ -1638,7 +1644,7 @@
 <hr/>
 
 <p>
-    When the iterator renders, it generates a list of Subscriptions for the current U/ser.
+    When the iterator renders, it generates a list of Subscriptions for the current User.
 </p>
 
 <hr />
@@ -1835,7 +1841,7 @@
 </p>
 
 <pre><code>
-  &lt;a href="/action2-mailreader/Subscription!edit.do?<strong>host=mail.yahoo.com</strong>">Edit</a>
+  &lt;a href="/action2-mailreader/Subscription!edit.do?<strong>host=mail.yahoo.com</strong>">Edit&lt;/a>
 </code></pre>
 
 
@@ -2244,9 +2250,8 @@
 </h4>
 
 <p>
-    The other DynaActionForms we've seen used only String properties.
-    SubscriptionForm is different in that it uses a Boolean type for the
-    AutoConnect property.
+    Like many applications, the MailReader uses mainly String properties.
+    One exception is the AutoConnect property of the Subscription object.
     On the HTML form, the AutoConnect property is represented by a checkbox,
     and checkboxes need to be handled differently that other controls.
 </p>
@@ -2324,7 +2329,7 @@
 <hr />
 
 <p>
-    The <strong>copySubscription</strong> method is a bit more inter testing.
+    The <strong>copySubscription</strong> method is a bit more interesting.
     The MailReader DAO layer API includes some immutable fields
     that can't be set once the object is created.
     Because key fields are immutable,



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


Mime
View raw message