You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/12/11 07:19:25 UTC

svn commit: r725594 - in /incubator/jspwiki/trunk: etc/ etc/i18n/templates/ src/com/ecyrd/jspwiki/action/ src/com/ecyrd/jspwiki/tags/ src/com/ecyrd/jspwiki/ui/ src/com/ecyrd/jspwiki/ui/stripes/ src/webdocs/ src/webdocs/templates/default/

Author: ajaquith
Date: Wed Dec 10 22:19:21 2008
New Revision: 725594

URL: http://svn.apache.org/viewvc?rev=725594&view=rev
Log:
Lots of work on user preferences/profile JSPs and ActionBeans; LostPassword.jsp has been assimilated into LoginActionBean. <rubs hands gleefully> Muhuhahaha!

Removed:
    incubator/jspwiki/trunk/src/webdocs/LostPassword.jsp
Modified:
    incubator/jspwiki/trunk/etc/i18n/templates/default.properties
    incubator/jspwiki/trunk/etc/web.xml
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/MessagesTag.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/TemplateManager.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/stripes/WikiActionBeanContext.java
    incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp
    incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp
    incubator/jspwiki/trunk/src/webdocs/templates/default/PreferencesContent.jsp

Modified: incubator/jspwiki/trunk/etc/i18n/templates/default.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/i18n/templates/default.properties?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/i18n/templates/default.properties (original)
+++ incubator/jspwiki/trunk/etc/i18n/templates/default.properties Wed Dec 10 22:19:21 2008
@@ -656,3 +656,71 @@
 
 javascript.prefs.areyousure=Without clicking the Save User Preferences button, \
 	your changes will be lost. Are you sure you want to exit this page?
+
+###############################################################################
+## Default Resource Bundle file for the Stripes Framework. Values should be
+## placed in here for the following:
+##   - Form Field Labels, unless you want users to see a non-localized, non-
+##     pretty name from the form field declaration (prettied up a little).
+##   - Error messages for:
+##       - Standard validation error messages
+##       - Converter error messages
+##       - Error messages used in your custom ActionBean classes
+###############################################################################
+
+# Resource strings used by the <stripes:errors> tag when there are no nested tags
+stripes.errors.header=<div style="color:#b72222; font-weight: bold">Please fix the following errors:</div><ol>
+stripes.errors.beforeError=<li style="color: #b72222;">
+stripes.errors.afterError=</li>
+stripes.errors.footer=</ol>
+
+# Resource strings used by the <stripes:errors> tag when displaying errors for a
+# specific field (e.g. <stripes:errors field="password"/>). If not supplied the
+# values above will be used instead.
+stripes.fieldErrors.header=
+stripes.fieldErrors.beforeError=<span style="color: #b72222;">
+stripes.fieldErrors.afterError=</span><br />
+stripes.fieldErrors.footer=
+
+# Resource strings used by the stripes:messages tag
+stripes.messages.header=<ul class="messages">
+stripes.messages.beforeMessage=<li>
+stripes.messages.afterMessage=</li>
+stripes.messages.footer=</ul>
+
+# Validation error messages produced by Stripes' built-in converter classes. These
+# are default error messages and can be overridden on per-field and per-form levels.
+# Using the 'invalidNumber' error for a field 'age' of a form posting to
+# '/user/Profile.action', the keys looked for (in order) would be:
+#      1: /user/Profile.action.age.invalidNumber
+#      2: /user/Profile.action.age.errorMessage
+#      3: age.errorMessage
+#      4: /user/Profile.action.invalidNumber
+#      5: converter.number.invalidNumber
+converter.number.invalidNumber=The value ({1}) entered in field {0} must be a valid number
+converter.byte.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.short.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.integer.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.float.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3}
+converter.enum.notAnEnumeratedValue=The value "{1}" is not a valid value for field {0}
+converter.date.invalidDate=The value ({1}) entered in field {0} must be a valid date
+converter.email.invalidEmail=The value ({1}) entered is not a valid email address
+converter.creditCard.invalidCreditCard=The value ({1}) entered is not a valid credit card number
+
+# Validation error messages produced by Stripes' annotation based validations. These
+# are default error messages and can be overridden on per-field and per-form levels.
+# Using the 'valueNotPresent' required field error for a field 'username' of a form
+# posting to '/user/Register.action', the keys looked for (in order) would be:
+#      1: /user/Register.action.username.valueNotPresent
+#      2: /user/Register.action.username.errorMessage
+#      3: username.errorMessage
+#      4: /user/Register.action.valueNotPresent
+#      5: validation.required.valueNotPresent
+validation.required.valueNotPresent={0} is a required field
+validation.minlength.valueTooShort={0} must be at least {2} characters long
+validation.maxlength.valueTooLong={0} must be no more than {2} characters long
+validation.minvalue.valueBelowMinimum=The minimum allowed value for {0} is {2}
+validation.maxvalue.valueAboveMaximum=The maximum allowed value for {0} is {2}
+validation.mask.valueDoesNotMatch=<em>{1}</em> is not a valid {0}
+validation.expression.valueFailedExpression=The value supplied ({1}) for field {0} is invalid
+validation.file.postBodyTooBig=Total upload size of {3} KB exceeds the maximum size of {2} KB

Modified: incubator/jspwiki/trunk/etc/web.xml
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/web.xml?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/web.xml (original)
+++ incubator/jspwiki/trunk/etc/web.xml Wed Dec 10 22:19:21 2008
@@ -132,6 +132,7 @@
         <filter-name>StripesFilter</filter-name>
         <url-pattern>*.jsp</url-pattern>
         <dispatcher>REQUEST</dispatcher>
+        <dispatcher>FORWARD</dispatcher>
     </filter-mapping>
 
     <filter-mapping>
@@ -158,9 +159,9 @@
       <listener-class>com.ecyrd.jspwiki.auth.SessionMonitor</listener-class>
    </listener>
    
-    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
-    <!--         Configuration of the Stripes dispatcher Servlet.            -->
-    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <!-- 
+        Stripes dispatcher Servlet.
+    -->
     <servlet>
         <servlet-name>StripesDispatcher</servlet-name>
         <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java Wed Dec 10 22:19:21 2008
@@ -1,8 +1,11 @@
 package com.ecyrd.jspwiki.action;
 
 import java.security.Principal;
+import java.text.MessageFormat;
 import java.util.ResourceBundle;
 
+import javax.mail.AuthenticationFailedException;
+import javax.mail.SendFailedException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -13,16 +16,23 @@
 import net.sourceforge.stripes.validation.Validate;
 import net.sourceforge.stripes.validation.ValidationErrors;
 
+import com.ecyrd.jspwiki.WikiContext;
 import com.ecyrd.jspwiki.WikiEngine;
 import com.ecyrd.jspwiki.WikiSession;
+import com.ecyrd.jspwiki.auth.NoSuchPrincipalException;
 import com.ecyrd.jspwiki.auth.WikiSecurityException;
 import com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule;
 import com.ecyrd.jspwiki.auth.login.CookieAuthenticationLoginModule;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
+import com.ecyrd.jspwiki.auth.user.UserDatabase;
+import com.ecyrd.jspwiki.auth.user.UserProfile;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
+import com.ecyrd.jspwiki.ui.TemplateManager;
 import com.ecyrd.jspwiki.ui.stripes.HandlerPermission;
 import com.ecyrd.jspwiki.ui.stripes.WikiRequestContext;
+import com.ecyrd.jspwiki.util.MailUtil;
+import com.ecyrd.jspwiki.util.TextUtil;
 
 @UrlBinding( "/Login.action" )
 public class LoginActionBean extends AbstractActionBean
@@ -56,6 +66,8 @@
         }
         return new RedirectResolution( builder.toString() );
     }
+    
+    private String m_email = null;
 
     private String m_username = null;
 
@@ -65,6 +77,15 @@
 
     private String m_redirect;
 
+    /**
+     * Returns the e-mail address.
+     * @return the e-mail address
+     */
+    public String getEmail()
+    {
+        return m_email;
+    }
+    
     public String getJ_password()
     {
         return m_password;
@@ -158,6 +179,16 @@
         return new RedirectResolution( ViewActionBean.class );
     }
 
+    /**
+     * Sets the e-mail property. Used by the {@link #resetPassword()} event.
+     * @param email the e-mail address
+     */
+    @Validate( required = true, on = "resetPassword", converter=net.sourceforge.stripes.validation.EmailTypeConverter.class )
+    public void setEmail( String email )
+    {
+        m_email = email;
+    }
+    
     @Validate( required = true, on = "login", minlength = 1, maxlength = 128 )
     public void setJ_password( String password )
     {
@@ -233,4 +264,86 @@
         return r;
     }
 
+    /**
+     * Event handler that resets the user's password, based on the e-mail address
+     * returned by {@link #getEmail()}.
+     * @return always returns <code>null</code>
+     */
+    @HandlesEvent( "resetPassword" )
+    public Resolution resetPassword()
+    {
+        String message = null;
+        ResourceBundle rb = getContext().getBundle( "CoreResources" );
+        
+        // Reset pw for account name
+        WikiEngine wiki = getContext().getEngine();
+        WikiSession wikiSession = getContext().getWikiSession();
+        UserDatabase userDatabase = wiki.getUserManager().getUserDatabase();
+        boolean success = false;
+
+        
+        try
+        {
+            // Look up the e-mail supplied by the user
+            UserProfile profile = userDatabase.findByEmail( m_email );
+            String email = profile.getEmail();
+            String randomPassword = TextUtil.generateRandomPassword();
+
+            // Compose the message e-mail body
+            Object[] args = { profile.getLoginName(), randomPassword,
+                             wiki.getURLConstructor().makeURL( WikiContext.NONE, "Login.jsp", true, "" ), wiki.getApplicationName() };
+            String mailMessage = MessageFormat.format( rb.getString( "lostpwd.newpassword.email" ), args );
+
+            // Compose the message subject line
+            args = new Object[] { wiki.getApplicationName() };
+            String mailSubject = MessageFormat.format( rb.getString( "lostpwd.newpassword.subject" ), args );
+            
+            // Send the message.
+            MailUtil.sendMessage( wiki, email, mailSubject, mailMessage );
+            log.info( "User " + email + " requested and received a new password." );
+
+            // Mail succeeded.  Now reset the password.
+            // If this fails, we're kind of screwed, because we already mailed it.
+            profile.setPassword( randomPassword );
+            userDatabase.save( profile );
+            success = true;
+        }
+        catch( NoSuchPrincipalException e )
+        {
+            Object[] args = { m_email };
+            message = MessageFormat.format( rb.getString( "lostpwd.nouser" ), args );
+            log.info( "Tried to reset password for non-existent user '" + m_email + "'" );
+        }
+        catch( SendFailedException e )
+        {
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got SendFailedException: " + e );
+        }
+        catch( AuthenticationFailedException e )
+        {
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got AuthenticationFailedException: " + e );
+        }
+        catch( Exception e )
+        {
+            message = rb.getString( "lostpwd.nomail" );
+            log.error( "Tried to reset password and got another exception: " + e );
+        }
+        
+        if( success )
+        {
+            wikiSession.addMessage( "resetpwok", rb.getString( "lostpwd.emailed" ) );
+            getContext().getRequest().setAttribute( "passwordreset", "done" );
+        }
+        else
+        // Error
+        {
+            wikiSession.addMessage( "resetpw", message );
+        }
+        
+        ForwardResolution r = getContext().getContentPage( this, TemplateManager.Template.VIEW, "LoginContent.jsp" );
+        r.addParameter( "tab", "lostpassword" );
+        return r;
+    }
+
 }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java Wed Dec 10 22:19:21 2008
@@ -11,8 +11,12 @@
 
 import com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
+import com.ecyrd.jspwiki.log.Logger;
+import com.ecyrd.jspwiki.log.LoggerFactory;
 import com.ecyrd.jspwiki.ui.EditorManager;
+import com.ecyrd.jspwiki.ui.TemplateManager;
 import com.ecyrd.jspwiki.ui.stripes.HandlerPermission;
+import com.ecyrd.jspwiki.ui.stripes.WikiActionBeanContext;
 import com.ecyrd.jspwiki.ui.stripes.WikiRequestContext;
 
 /**
@@ -21,6 +25,8 @@
 @UrlBinding( "/UserPreferences.action" )
 public class UserPreferencesActionBean extends AbstractActionBean
 {
+    private Logger log = LoggerFactory.getLogger( "JSPWiki" );
+
     private String m_assertedName = null;
 
     private String m_editor = null;
@@ -62,12 +68,11 @@
      * 
      * @return a redirection to the front page
      */
-    @DefaultHandler
     @HandlesEvent( "createAssertedName" )
     @HandlerPermission( permissionClass = WikiPermission.class, target = "${context.engine.applicationName}", actions = WikiPermission.EDIT_PREFERENCES_ACTION )
-    @WikiRequestContext( "prefs" )
     public Resolution createAssertedName()
     {
+        // FIXME: should reload preferences (see Preferences.reloadPreferences)
         if( !getContext().getWikiSession().isAuthenticated() )
         {
             HttpServletRequest request = getContext().getRequest();
@@ -75,6 +80,13 @@
             String assertedName = request.getParameter( "assertedName" );
             CookieAssertionLoginModule.setUserCookie( response, assertedName );
         }
+        if( m_redirect != null )
+        {
+            RedirectResolution r = new RedirectResolution( ViewActionBean.class );
+            r.addParameter( "page", m_redirect );
+            log.info( "Redirecting user to wiki page " + m_redirect );
+            return r;
+        }
         return new RedirectResolution( "/" );
     }
 
@@ -149,4 +161,21 @@
     {
         return m_redirect;
     }
+
+    /**
+     * Handler for displaying user preferences that simply forwards to the
+     * preferences display JSP <code>PreferencesContent.jsp</code>.
+     * 
+     * @return a forward to the content template
+     */
+    @DefaultHandler
+    @HandlesEvent("prefs")
+    @HandlerPermission( permissionClass = WikiPermission.class, target = "${context.engine.applicationName}", actions = WikiPermission.EDIT_PREFERENCES_ACTION )
+    @WikiRequestContext( "prefs" )
+    public Resolution view()
+    {
+        WikiActionBeanContext context = getContext();
+        TemplateManager.addResourceRequest( context, "script", "scripts/jspwiki-prefs.js" );
+        return context.getContentPage( this, TemplateManager.Template.VIEW, "PreferencesContent.jsp" );
+    }
 }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java Wed Dec 10 22:19:21 2008
@@ -18,6 +18,7 @@
 import com.ecyrd.jspwiki.auth.user.UserProfile;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
+import com.ecyrd.jspwiki.ui.TemplateManager;
 import com.ecyrd.jspwiki.ui.stripes.HandlerPermission;
 import com.ecyrd.jspwiki.ui.stripes.WikiActionBeanContext;
 import com.ecyrd.jspwiki.ui.stripes.WikiRequestContext;
@@ -258,7 +259,7 @@
     @WikiRequestContext( "profile" )
     public Resolution view()
     {
-        return new ForwardResolution( "/UserPreferences.jsp" );
+        return getContext().getContentPage( this, TemplateManager.Template.VIEW, "PreferencesContent.jsp" );
     }
 
 }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java Wed Dec 10 22:19:21 2008
@@ -12,6 +12,7 @@
 import com.ecyrd.jspwiki.auth.permissions.PagePermission;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
+import com.ecyrd.jspwiki.ui.TemplateManager;
 import com.ecyrd.jspwiki.ui.stripes.HandlerPermission;
 import com.ecyrd.jspwiki.ui.stripes.WikiRequestContext;
 
@@ -134,7 +135,7 @@
     @WikiRequestContext("view")
     public Resolution view()
     {
-        return getContext().getEngine().getTemplateManager().getContentPage( this, "ViewTemplate.jsp", "PageContent.jsp" );
+        return getContext().getContentPage( this, TemplateManager.Template.VIEW, "PageContent.jsp" );
     }
     
     /**
@@ -146,7 +147,7 @@
     @WikiRequestContext("info")
     public Resolution info()
     {
-        return getContext().getEngine().getTemplateManager().getContentPage( this, "ViewTemplate.jsp", "InfoContent.jsp" );
+        return getContext().getContentPage( this, TemplateManager.Template.VIEW, "InfoContent.jsp" );
     }
-    
+
 }

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/MessagesTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/MessagesTag.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/MessagesTag.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/MessagesTag.java Wed Dec 10 22:19:21 2008
@@ -107,13 +107,16 @@
             List<String> messageStrings = new ArrayList<String>();
 
             // Add all of the Stripes validation errors first (all fields, even global errors)
-            ValidationErrors errors = m_wikiActionBean.getContext().getValidationErrors();
-            for ( List<ValidationError> fieldErrors : errors.values() ) 
+            if ( "error".equals( m_div) )
             {
-                for ( ValidationError error : fieldErrors )
+                ValidationErrors errors = m_wikiActionBean.getContext().getValidationErrors();
+                for ( List<ValidationError> fieldErrors : errors.values() ) 
                 {
-                    String message = error.getMessage( m_wikiActionBean.getContext().getLocale() );
-                    messageStrings.add( message );
+                    for ( ValidationError error : fieldErrors )
+                    {
+                        String message = error.getMessage( m_wikiActionBean.getContext().getLocale() );
+                        messageStrings.add( message );
+                    }
                 }
             }
 

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/TemplateManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/TemplateManager.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/TemplateManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/TemplateManager.java Wed Dec 10 22:19:21 2008
@@ -32,21 +32,17 @@
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.jstl.fmt.LocaleSupport;
 
-import net.sourceforge.stripes.action.ForwardResolution;
-
 import org.apache.commons.lang.StringUtils;
 
 import com.ecyrd.jspwiki.InternalWikiException;
 import com.ecyrd.jspwiki.WikiContext;
 import com.ecyrd.jspwiki.WikiEngine;
-import com.ecyrd.jspwiki.action.WikiActionBean;
 import com.ecyrd.jspwiki.action.WikiContextFactory;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
 import com.ecyrd.jspwiki.modules.ModuleManager;
 import com.ecyrd.jspwiki.preferences.Preferences;
 import com.ecyrd.jspwiki.preferences.Preferences.TimeFormat;
-import com.ecyrd.jspwiki.ui.stripes.WikiActionBeanContext;
 
 /**
  *  This class takes care of managing JSPWiki templates.  This class also provides
@@ -57,6 +53,36 @@
 public class TemplateManager
     extends ModuleManager
 {
+    /**
+     * Enum that specifies the two types of templates: {@link #VIEW} and {@link #EDIT}.
+     */
+    public enum Template { 
+        /** Template used for viewing things. */
+        VIEW("ViewTemplate.jsp"), 
+        /** Template used for editing things. */
+        EDIT("EditTemplate.jsp");
+        
+        private final String m_template;
+        
+        /**
+         * Package-private constructor.
+         * @param template the name of the template
+         */
+        Template( String template )
+        {
+            m_template = template;
+        }
+        
+        /**
+         * Returns the JSP for the template.
+         * @return
+         */
+        public String template()
+        {
+            return m_template;
+        }
+    }
+    
     private static final String SKIN_DIRECTORY = "skins";
 
     /**
@@ -231,20 +257,6 @@
     }
 
     /**
-     * Returns a Stripes ForwardResolution to the content page
-     * @return
-     */
-    public ForwardResolution getContentPage( WikiActionBean actionBean, String templateJsp, String contentJsp )
-    {
-        WikiActionBeanContext wikiContext = actionBean.getContext();
-        wikiContext.setVariable( "contentTemplate", contentJsp );
-        String contentPage = findResource( wikiContext.getServletContext(), wikiContext.getTemplate(), templateJsp );
-        
-        ForwardResolution r = new ForwardResolution( contentPage );
-        return r;
-    }
-
-    /**
      *  An utility method for finding a JSP page.  It searches only under
      *  either current context or by the absolute name.
      *

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/stripes/WikiActionBeanContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/stripes/WikiActionBeanContext.java?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/stripes/WikiActionBeanContext.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/ui/stripes/WikiActionBeanContext.java Wed Dec 10 22:19:21 2008
@@ -8,11 +8,14 @@
 import javax.servlet.http.HttpServletRequest;
 
 import net.sourceforge.stripes.action.ActionBeanContext;
+import net.sourceforge.stripes.action.ForwardResolution;
 
 import com.ecyrd.jspwiki.WikiContext;
 import com.ecyrd.jspwiki.WikiEngine;
 import com.ecyrd.jspwiki.WikiPage;
 import com.ecyrd.jspwiki.WikiSession;
+import com.ecyrd.jspwiki.action.WikiActionBean;
+import com.ecyrd.jspwiki.ui.TemplateManager;
 
 /**
  * <p>
@@ -182,6 +185,19 @@
     }
 
     /**
+     * Returns a Stripes ForwardResolution for the full path to the resolved content page.
+     * @return the resolution
+     */
+    public ForwardResolution getContentPage( WikiActionBean actionBean, TemplateManager.Template template, String contentJsp )
+    {
+        TemplateManager mgr = getEngine().getTemplateManager();
+        WikiActionBeanContext wikiContext = actionBean.getContext();
+        wikiContext.setVariable( "contentTemplate", contentJsp );
+        String contentPage = mgr.findResource( wikiContext, wikiContext.getTemplate(), template.template() );
+        return new ForwardResolution( contentPage );
+    }
+
+    /**
      *  {@inheritDoc}
      */
     public Principal getCurrentUser()

Modified: incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp Wed Dec 10 22:19:21 2008
@@ -1,107 +1,2 @@
-<%@ page import="com.ecyrd.jspwiki.log.Logger" %>
-<%@ page import="com.ecyrd.jspwiki.log.LoggerFactory" %>
-<%@ page import="com.ecyrd.jspwiki.VariableManager" %>
-<%@ page import="com.ecyrd.jspwiki.WikiContext" %>
-<%@ page import="com.ecyrd.jspwiki.WikiSession" %>
-<%@ page import="com.ecyrd.jspwiki.WikiEngine" %>
-<%@ page import="com.ecyrd.jspwiki.auth.UserManager" %>
-<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
-<%@ page import="com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule" %>
-<%@ page import="com.ecyrd.jspwiki.auth.user.DuplicateUserException" %>
-<%@ page import="com.ecyrd.jspwiki.auth.user.UserProfile" %>
-<%@ page import="com.ecyrd.jspwiki.workflow.DecisionRequiredException" %>
-<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
-<%@ page import="com.ecyrd.jspwiki.ui.TemplateManager" %>
-<%@ page import="com.ecyrd.jspwiki.preferences.*" %>
-<%@ page errorPage="/Error.jsp" %>
-<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
 <%@ taglib uri="/WEB-INF/stripes.tld" prefix="stripes" %>
-<stripes:useActionBean beanclass="com.ecyrd.jspwiki.action.UserPreferencesActionBean" event="createAssertedName" />
-
-<%! 
-    Logger log = LoggerFactory.getLogger("JSPWiki"); 
-%>
-
-<%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-    // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.PREFS );
-    
-    // Extract the user profile and action attributes
-    UserManager userMgr = wiki.getUserManager();
-    WikiSession wikiSession = wikiContext.getWikiSession();
-
-/* FIXME: Obsoslete 
-    if( request.getParameter(EditorManager.PARA_EDITOR) != null )
-    {
-    	String editor = request.getParameter(EditorManager.PARA_EDITOR);
-    	session.setAttribute(EditorManager.PARA_EDITOR,editor);
-    }
-*/
-
-    // Are we saving the profile?
-    if( "saveProfile".equals(request.getParameter("action")) )
-    {
-        UserProfile profile = userMgr.parseProfile( wikiContext );
-         
-        // Validate the profile
-        userMgr.validateProfile( wikiContext, profile );
-
-        // If no errors, save the profile now & refresh the principal set!
-        if ( wikiSession.getMessages( "profile" ).length == 0 )
-        {
-            try
-            {
-                userMgr.setUserProfile( wikiSession, profile );
-                CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
-            }
-            catch( DuplicateUserException e )
-            {
-                // User collision! (full name or wiki name already taken)
-                wikiSession.addMessage( "profile", e.getMessage() );
-            }
-            catch( DecisionRequiredException e )
-            {
-                String redirect = wiki.getURL(WikiContext.VIEW,"ApprovalRequiredForUserProfiles",null,true);
-                response.sendRedirect( redirect );
-                return;
-            }
-            catch( WikiSecurityException e )
-            {
-                // Something went horribly wrong! Maybe it's an I/O error...
-                wikiSession.addMessage( "profile", e.getMessage() );
-            }
-        }
-        if ( wikiSession.getMessages( "profile" ).length == 0 )
-        {
-            String redirectPage = request.getParameter( "redirect" );
-            response.sendRedirect( wiki.getViewURL(redirectPage) );
-            return;
-        }
-    }
-    if( "setAssertedName".equals(request.getParameter("action")) )
-    {
-        Preferences.reloadPreferences(pageContext);
-        
-        String assertedName = request.getParameter("assertedName");
-        CookieAssertionLoginModule.setUserCookie( response, assertedName );
-
-        String redirectPage = request.getParameter( "redirect" );
-        String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
-
-        log.info( "Redirecting user to " + viewUrl );
-        response.sendRedirect( viewUrl );
-        return;
-    }
-    if( "clearAssertedName".equals(request.getParameter("action")) )
-    {
-        CookieAssertionLoginModule.clearUserCookie( response );
-        response.sendRedirect( wikiContext.getURL(WikiContext.NONE,"Logout.jsp") );
-        return;
-    }
-    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
-%><wiki:Include page="<%=contentPage%>" />
-
+<stripes:useActionBean beanclass="com.ecyrd.jspwiki.action.UserPreferencesActionBean" event="prefs" executeResolution="true" />

Modified: incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/templates/default/LoginContent.jsp Wed Dec 10 22:19:21 2008
@@ -92,8 +92,8 @@
 <wiki:Tab id="lostpassword" titleKey="login.lostpw.tab">
 
 <div class="center">
-<stripes:form action="/LostPassword.jsp" id="lostpw" class="wikiform" method="post" acceptcharset="UTF-8">
-
+<stripes:form beanclass="com.ecyrd.jspwiki.action.LoginActionBean" id="lostpw" class="wikiform" method="post" acceptcharset="UTF-8">
+  <stripes:param name="tab" value="lostpassword" />
   <h3><fmt:message key="login.lostpw.heading" /></h3>
 
   <c:choose>
@@ -119,8 +119,8 @@
     </tr>
     </c:if>
     <tr>
-      <td><stripes:label for="name" name="login.lostpw.name" /></td>
-      <td><stripes:text size="24" name="name" id="name" /></td>
+      <td><stripes:label for="email" name="login.lostpw.name" /></td>
+      <td><stripes:text size="24" name="email" id="email" /></td>
     </tr>
     <tr>
       <td>&nbsp;</td>

Modified: incubator/jspwiki/trunk/src/webdocs/templates/default/PreferencesContent.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/templates/default/PreferencesContent.jsp?rev=725594&r1=725593&r2=725594&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/templates/default/PreferencesContent.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/templates/default/PreferencesContent.jsp Wed Dec 10 22:19:21 2008
@@ -1,14 +1,4 @@
 <%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
-<%@ page import="com.ecyrd.jspwiki.*" %>
-<%@ page import="com.ecyrd.jspwiki.ui.*" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
-<%@ page import="com.ecyrd.jspwiki.action.WikiContextFactory" %>
-<% 
-  WikiContext context = WikiContextFactory.findContext( pageContext ); 
-  TemplateManager.addResourceRequest( context, "script", "scripts/jspwiki-prefs.js" );
-%>
-
 <wiki:TabbedSection defaultTab="${param.tab}">
 
   <wiki:Tab id="prefs" titleKey="prefs.tab.prefs" accesskey="p">