struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wsm...@apache.org
Subject svn commit: r349283 - in /struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader: BaseViewController.java Logon.java Registration.java
Date Sun, 27 Nov 2005 19:27:28 GMT
Author: wsmoak
Date: Sun Nov 27 11:27:21 2005
New Revision: 349283

URL: http://svn.apache.org/viewcvs?rev=349283&view=rev
Log:
Minor changes to Shale MailReader
  Remove BaseViewController methods that are inherited from AbstractFacesBean, but comment
the usage so it's not a mystery.
  Simplify the logic in Registration's prerender method, which was testing the same condition
twice.
  Note the location of a NPE, possibly related to a session timeout, that needs to be debugged.
  Make it clearer that returning null is what causes the logon page to be re-displayed.

Modified:
    struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/BaseViewController.java
    struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Logon.java
    struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Registration.java

Modified: struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/BaseViewController.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/BaseViewController.java?rev=349283&r1=349282&r2=349283&view=diff
==============================================================================
--- struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/BaseViewController.java
(original)
+++ struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/BaseViewController.java
Sun Nov 27 11:27:21 2005
@@ -44,37 +44,12 @@
 
 
     /**
-     * <p>Return the named bean from request, session, or application scope.
-     * If this is a managed bean, it might also get created as a side effect.
-     * Return <code>null</code> if no such bean can be found or created.</p>
-     *
-     * @param name Name of the desired bean
-     */
-    protected Object getBean(String name) {
-
-        FacesContext context = getFacesContext();
-        return context.getApplication().getVariableResolver().
-          resolveVariable(context, name);
-
-    }
-
-
-    /**
-     * <p>Return the <code>FacesContext</code> instance for the
-     * current request.</p>
-     */
-    protected FacesContext getFacesContext() {
-
-        return FacesContext.getCurrentInstance();
-
-    }
-
-
-    /**
      * <p>Return the state saving bean for this user's transaction state.</p>
      */
     protected State getState() {
-
+        
+        // Look up the state saving bean,
+        // using the 'getBean' method inherited from AbstractFacesBean
         return (State) getBean("state");
 
     }
@@ -85,6 +60,8 @@
      */
     protected UserDatabase getUserDatabase() {
 
+        // Look up the DAO for the user database,
+        // using the 'getBean' method inherited from AbstractFacesBean
         return (UserDatabase) getBean("database");
 
     }

Modified: struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Logon.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Logon.java?rev=349283&r1=349282&r2=349283&view=diff
==============================================================================
--- struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Logon.java
(original)
+++ struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Logon.java
Sun Nov 27 11:27:21 2005
@@ -111,10 +111,12 @@
             return "success";
         }
 
-        // Append an error message and return to the logon page
+        // Append an error message
         // FIXME - use Commons Resources to localize this message
         getFacesContext().addMessage(null,
           new FacesMessage("Invalid username or password, please try again"));
+        
+        // Redisplay the logon page
         return null;
 
     }

Modified: struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Registration.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Registration.java?rev=349283&r1=349282&r2=349283&view=diff
==============================================================================
--- struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Registration.java
(original)
+++ struts/shale/trunk/mailreader/src/java/org/apache/shale/examples/mailreader/Registration.java
Sun Nov 27 11:27:21 2005
@@ -370,9 +370,8 @@
 
 
     /**
-     * <p>If this is not a postack, and we are in EDIT mode, prepopulate
-     * the field values for the user registration update form.  Also, if
-     * we are in EDIT mode, and this is not a postback, retrieve the
+     * <p>If this is not a postback, and we are in EDIT mode, prepopulate
+     * the field values for the user registration update form and retrieve the
      * subscriptions for the currently logged in user.  (If this is a
      * postback, we will have done this already in <code>init()</code>.)</p>
      */
@@ -388,19 +387,17 @@
         // The first time in, prepopulate our input field values
         User user = state.getUser();
         if (!isPostBack()) {
-            setUsername(user.getUsername());
+            setUsername(user.getUsername()); //FIXME: NPE (after session timeout?)
             setPassword("");
             setPassword2("");
             setFullName(user.getFullName());
             setFromAddress(user.getFromAddress());
             setReplyToAddress(user.getReplyToAddress());
-        }
 
         // Look up the subscriptions for the currently logged on user,
         // if we have not done so already.
         // If we were using a real database, this is where executing the
         // query and opening the result set would occur
-        if (!isPostBack()) {
             setSubscriptions(user.getSubscriptions());
         }
 



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


Mime
View raw message