dgraham 2003/08/16 11:29:09
Modified: src/example/org/apache/struts/webapp/example
SubscriptionForm.java SaveSubscriptionAction.java
SaveRegistrationAction.java RegistrationForm.java
LogonAction.java LogoffAction.java
EditSubscriptionAction.java
EditRegistrationAction.java
Log:
Formatting, bad imports, changed ActionError to ActionMessage.
Revision Changes Path
1.5 +12 -11
jakarta-struts/src/example/org/apache/struts/webapp/example/SubscriptionForm.java
Index: SubscriptionForm.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/SubscriptionForm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SubscriptionForm.java 11 Jan 2003 03:08:23 -0000 1.4
+++ SubscriptionForm.java 16 Aug 2003 18:29:09 -0000 1.5
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,10 +64,11 @@
import javax.servlet.http.HttpServletRequest;
-import org.apache.struts.action.ActionError;
+
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
/**
@@ -301,19 +302,19 @@
if ((host == null) || (host.length() < 1))
errors.add("host",
- new ActionError("error.host.required"));
+ new ActionMessage("error.host.required"));
if ((username == null) || (username.length() < 1))
errors.add("username",
- new ActionError("error.username.required"));
+ new ActionMessage("error.username.required"));
if ((password == null) || (password.length() < 1))
errors.add("password",
- new ActionError("error.password.required"));
+ new ActionMessage("error.password.required"));
if ((type == null) || (type.length() < 1))
errors.add("type",
- new ActionError("error.type.required"));
+ new ActionMessage("error.type.required"));
else if (!"imap".equals(type) && !"pop3".equals(type))
errors.add("type",
- new ActionError("error.type.invalid", type));
+ new ActionMessage("error.type.invalid", type));
return (errors);
1.14 +70 -78
jakarta-struts/src/example/org/apache/struts/webapp/example/SaveSubscriptionAction.java
Index: SaveSubscriptionAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/SaveSubscriptionAction.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- SaveSubscriptionAction.java 18 Jan 2003 19:48:56 -0000 1.13
+++ SaveSubscriptionAction.java 16 Aug 2003 18:29:09 -0000 1.14
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,16 +59,15 @@
*
*/
-
package org.apache.struts.webapp.example;
-
import java.lang.reflect.InvocationTargetException;
-import java.util.Locale;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -78,7 +77,6 @@
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;
-
/**
* Implementation of <strong>Action</strong> that validates and creates or
* updates the mail subscription entered by the user.
@@ -89,20 +87,15 @@
public final class SaveSubscriptionAction extends Action {
-
// ----------------------------------------------------- Instance Variables
-
/**
* The <code>Log</code> instance for this application.
*/
- private Log log =
- LogFactory.getLog("org.apache.struts.webapp.Example");
-
+ private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
// --------------------------------------------------------- Public Methods
-
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
@@ -118,86 +111,86 @@
* @exception Exception if the application business logic throws
* an exception
*/
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- // Extract attributes and parameters we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
- HttpSession session = request.getSession();
- SubscriptionForm subform = (SubscriptionForm) form;
- String action = subform.getAction();
- if (action == null) {
- action = "?";
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ // Extract attributes and parameters we will need
+ MessageResources messages = getResources(request);
+ HttpSession session = request.getSession();
+ SubscriptionForm subform = (SubscriptionForm) form;
+ String action = subform.getAction();
+ if (action == null) {
+ action = "?";
}
if (log.isDebugEnabled()) {
- log.debug("SaveSubscriptionAction: Processing " + action +
- " action");
+ log.debug("SaveSubscriptionAction: Processing " + action + " action");
}
- // Is there a currently logged on user?
- User user = (User) session.getAttribute(Constants.USER_KEY);
- if (user == null) {
+ // Is there a currently logged on user?
+ User user = (User) session.getAttribute(Constants.USER_KEY);
+ if (user == null) {
if (log.isTraceEnabled()) {
- log.trace(" User is not logged on in session "
- + session.getId());
+ log.trace(" User is not logged on in session " + session.getId());
}
- return (mapping.findForward("logon"));
+ return (mapping.findForward("logon"));
}
- // Was this transaction cancelled?
- if (isCancelled(request)) {
+ // Was this transaction cancelled?
+ if (isCancelled(request)) {
if (log.isTraceEnabled()) {
- log.trace(" Transaction '" + action +
- "' was cancelled");
+ log.trace(" Transaction '" + action + "' was cancelled");
}
session.removeAttribute(Constants.SUBSCRIPTION_KEY);
- return (mapping.findForward("success"));
- }
+ return (mapping.findForward("success"));
+ }
- // Is there a related Subscription object?
- Subscription subscription =
- (Subscription) session.getAttribute(Constants.SUBSCRIPTION_KEY);
+ // Is there a related Subscription object?
+ Subscription subscription =
+ (Subscription) session.getAttribute(Constants.SUBSCRIPTION_KEY);
if ("Create".equals(action)) {
- subscription =
- user.createSubscription(request.getParameter("host"));
+ subscription = user.createSubscription(request.getParameter("host"));
}
- if (subscription == null) {
+ if (subscription == null) {
if (log.isTraceEnabled()) {
- log.trace(" Missing subscription for user '" +
- user.getUsername() + "'");
+ log.trace(
+ " Missing subscription for user '" + user.getUsername() + "'");
}
- response.sendError(HttpServletResponse.SC_BAD_REQUEST,
- messages.getMessage("error.noSubscription"));
- return (null);
- }
+ response.sendError(
+ HttpServletResponse.SC_BAD_REQUEST,
+ messages.getMessage("error.noSubscription"));
+ return (null);
+ }
- // Was this transaction a Delete?
- if (action.equals("Delete")) {
+ // Was this transaction a Delete?
+ if (action.equals("Delete")) {
if (log.isTraceEnabled()) {
- log.trace(" Deleting mail server '" +
- subscription.getHost() + "' for user '" +
- user.getUsername() + "'");
+ log.trace(
+ " Deleting mail server '"
+ + subscription.getHost()
+ + "' for user '"
+ + user.getUsername()
+ + "'");
}
user.removeSubscription(subscription);
- session.removeAttribute(Constants.SUBSCRIPTION_KEY);
+ session.removeAttribute(Constants.SUBSCRIPTION_KEY);
try {
- UserDatabase database = (UserDatabase)
- servlet.getServletContext().
- getAttribute(Constants.DATABASE_KEY);
+ UserDatabase database =
+ (UserDatabase) servlet.getServletContext().getAttribute(
+ Constants.DATABASE_KEY);
database.save();
} catch (Exception e) {
log.error("Database save", e);
}
- return (mapping.findForward("success"));
- }
+ return (mapping.findForward("success"));
+ }
- // All required validations were done by the form itself
+ // All required validations were done by the form itself
- // Update the persistent subscription information
+ // Update the persistent subscription information
if (log.isTraceEnabled()) {
log.trace(" Populating database from form bean");
}
@@ -215,30 +208,29 @@
}
try {
- UserDatabase database = (UserDatabase)
- servlet.getServletContext().
- getAttribute(Constants.DATABASE_KEY);
+ UserDatabase database =
+ (UserDatabase) servlet.getServletContext().getAttribute(
+ Constants.DATABASE_KEY);
database.save();
} catch (Exception e) {
log.error("Database save", e);
}
- // Remove the obsolete form bean and current subscription
- if (mapping.getAttribute() != null) {
+ // Remove the obsolete form bean and current subscription
+ if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
- session.removeAttribute(Constants.SUBSCRIPTION_KEY);
+ session.removeAttribute(Constants.SUBSCRIPTION_KEY);
- // Forward control to the specified success URI
+ // Forward control to the specified success URI
if (log.isTraceEnabled()) {
log.trace(" Forwarding to success page");
}
- return (mapping.findForward("success"));
+ return (mapping.findForward("success"));
}
-
}
1.15 +91 -88
jakarta-struts/src/example/org/apache/struts/webapp/example/SaveRegistrationAction.java
Index: SaveRegistrationAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/SaveRegistrationAction.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SaveRegistrationAction.java 11 Jan 2003 03:08:23 -0000 1.14
+++ SaveRegistrationAction.java 16 Aug 2003 18:29:09 -0000 1.15
@@ -59,27 +59,24 @@
*
*/
-
package org.apache.struts.webapp.example;
-
import java.lang.reflect.InvocationTargetException;
-import java.util.Locale;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
-import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.util.MessageResources;
-
+import org.apache.struts.action.ActionMessage;
/**
* Implementation of <strong>Action</strong> that validates and creates or
@@ -92,20 +89,15 @@
public final class SaveRegistrationAction extends Action {
-
// ----------------------------------------------------- Instance Variables
-
/**
* The <code>Log</code> instance for this application.
*/
- private Log log =
- LogFactory.getLog("org.apache.struts.webapp.Example");
-
+ private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
// --------------------------------------------------------- Public Methods
-
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
@@ -121,102 +113,110 @@
* @exception Exception if the application business logic throws
* an exception
*/
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- // Extract attributes and parameters we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
- HttpSession session = request.getSession();
- RegistrationForm regform = (RegistrationForm) form;
- String action = regform.getAction();
- if (action == null) {
- action = "Create";
- }
- UserDatabase database = (UserDatabase)
- servlet.getServletContext().getAttribute(Constants.DATABASE_KEY);
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ // Extract attributes and parameters we will need
+ HttpSession session = request.getSession();
+ RegistrationForm regform = (RegistrationForm) form;
+ String action = regform.getAction();
+ if (action == null) {
+ action = "Create";
+ }
+
+ UserDatabase database =
+ (UserDatabase) servlet.getServletContext().getAttribute(
+ Constants.DATABASE_KEY);
+
if (log.isDebugEnabled()) {
- log.debug("SaveRegistrationAction: Processing " + action +
- " action");
+ log.debug("SaveRegistrationAction: Processing " + action + " action");
}
- // Is there a currently logged on user (unless creating)?
- User user = (User) session.getAttribute(Constants.USER_KEY);
- if (!"Create".equals(action) && (user == null)) {
+ // Is there a currently logged on user (unless creating)?
+ User user = (User) session.getAttribute(Constants.USER_KEY);
+ if (!"Create".equals(action) && (user == null)) {
if (log.isTraceEnabled()) {
- log.trace(" User is not logged on in session "
- + session.getId());
+ log.trace(" User is not logged on in session " + session.getId());
}
- return (mapping.findForward("logon"));
+ return (mapping.findForward("logon"));
}
- // Was this transaction cancelled?
- if (isCancelled(request)) {
+ // Was this transaction cancelled?
+ if (isCancelled(request)) {
if (log.isTraceEnabled()) {
- log.trace(" Transaction '" + action +
- "' was cancelled");
+ log.trace(" Transaction '" + action + "' was cancelled");
}
- session.removeAttribute(Constants.SUBSCRIPTION_KEY);
- return (mapping.findForward("success"));
- }
+ session.removeAttribute(Constants.SUBSCRIPTION_KEY);
+ return (mapping.findForward("success"));
+ }
// Validate the transactional control token
- ActionErrors errors = new ActionErrors();
+ ActionErrors errors = new ActionErrors();
if (log.isTraceEnabled()) {
log.trace(" Checking transactional control token");
}
+
if (!isTokenValid(request)) {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("error.transaction.token"));
+ errors.add(
+ ActionErrors.GLOBAL_ERROR,
+ new ActionMessage("error.transaction.token"));
}
+
resetToken(request);
- // Validate the request parameters specified by the user
+ // Validate the request parameters specified by the user
if (log.isTraceEnabled()) {
log.trace(" Performing extra validations");
}
- String value = null;
- value = regform.getUsername();
- if (("Create".equals(action)) &&
- (database.findUser(value) != null)) {
- errors.add("username",
- new ActionError("error.username.unique",
- regform.getUsername()));
- }
- if ("Create".equals(action)) {
- value = regform.getPassword();
- if ((value == null) || (value.length() <1)) {
- errors.add("password",
- new ActionError("error.password.required"));
- }
- value = regform.getPassword2();
- if ((value == null) || (value.length() < 1)) {
- errors.add("password2",
- new ActionError("error.password2.required"));
- }
- }
-
- // Report any errors we have discovered back to the original form
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
+
+ String value = null;
+ value = regform.getUsername();
+ if (("Create".equals(action)) && (database.findUser(value) != null)) {
+ errors.add(
+ "username",
+ new ActionMessage("error.username.unique", regform.getUsername()));
+ }
+
+ if ("Create".equals(action)) {
+ value = regform.getPassword();
+ if ((value == null) || (value.length() < 1)) {
+ errors.add("password", new
ActionMessage("error.password.required"));
+ }
+
+ value = regform.getPassword2();
+
+ if ((value == null) || (value.length() < 1)) {
+ errors.add(
+ "password2",
+ new ActionMessage("error.password2.required"));
+ }
+ }
+
+ // Report any errors we have discovered back to the original form
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
saveToken(request);
return (mapping.getInputForward());
- }
+ }
- // Update the user's persistent profile information
+ // Update the user's persistent profile information
try {
if ("Create".equals(action)) {
user = database.createUser(regform.getUsername());
}
+
String oldPassword = user.getPassword();
PropertyUtils.copyProperties(user, regform);
- if ((regform.getPassword() == null) ||
- (regform.getPassword().length() < 1)) {
+ if ((regform.getPassword() == null)
+ || (regform.getPassword().length() < 1)) {
+
user.setPassword(oldPassword);
}
+
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null) {
@@ -236,29 +236,32 @@
}
// Log the user in if appropriate
- if ("Create".equals(action)) {
- session.setAttribute(Constants.USER_KEY, user);
+ if ("Create".equals(action)) {
+ session.setAttribute(Constants.USER_KEY, user);
if (log.isTraceEnabled()) {
- log.trace(" User '" + user.getUsername() +
- "' logged on in session " + session.getId());
+ log.trace(
+ " User '"
+ + user.getUsername()
+ + "' logged on in session "
+ + session.getId());
}
- }
+ }
- // Remove the obsolete form bean
- if (mapping.getAttribute() != null) {
+ // Remove the obsolete form bean
+ if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
- // Forward control to the specified success URI
+ // Forward control to the specified success URI
if (log.isTraceEnabled()) {
log.trace(" Forwarding to success page");
}
- return (mapping.findForward("success"));
+
+ return (mapping.findForward("success"));
}
-
}
1.8 +7 -6
jakarta-struts/src/example/org/apache/struts/webapp/example/RegistrationForm.java
Index: RegistrationForm.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/RegistrationForm.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RegistrationForm.java 18 Jan 2003 19:48:56 -0000 1.7
+++ RegistrationForm.java 16 Aug 2003 18:29:09 -0000 1.8
@@ -64,9 +64,10 @@
import javax.servlet.http.HttpServletRequest;
-import org.apache.struts.action.ActionError;
+
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.ValidatorForm;
@@ -340,7 +341,7 @@
// Only need crossfield validations here
if (!password.equals(password2)) {
errors.add("password2",
- new ActionError("error.password.match"));
+ new ActionMessage("error.password.match"));
}
return errors;
1.15 +57 -65
jakarta-struts/src/example/org/apache/struts/webapp/example/LogonAction.java
Index: LogonAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/LogonAction.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- LogonAction.java 11 Jan 2003 03:08:23 -0000 1.14
+++ LogonAction.java 16 Aug 2003 18:29:09 -0000 1.15
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,25 +59,22 @@
*
*/
-
package org.apache.struts.webapp.example;
-import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
-import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
import org.apache.struts.util.ModuleException;
-import org.apache.struts.util.MessageResources;
-import org.apache.commons.beanutils.PropertyUtils;
-
/**
* Implementation of <strong>Action</strong> that validates a user logon.
@@ -85,23 +82,17 @@
* @author Craig R. McClanahan
* @version $Revision$ $Date$
*/
-
public final class LogonAction extends Action {
-
// ----------------------------------------------------- Instance Variables
-
/**
* The <code>Log</code> instance for this application.
*/
- private Log log =
- LogFactory.getLog("org.apache.struts.webapp.Example");
-
+ private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
// --------------------------------------------------------- Public Methods
-
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
@@ -116,68 +107,70 @@
*
* @exception Exception if business logic throws an exception
*/
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- // Extract attributes we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
- User user = null;
-
- // Validate the request parameters specified by the user
- ActionErrors errors = new ActionErrors();
- String username = (String)
- PropertyUtils.getSimpleProperty(form, "username");
- String password = (String)
- PropertyUtils.getSimpleProperty(form, "password");
- UserDatabase database = (UserDatabase)
- servlet.getServletContext().getAttribute(Constants.DATABASE_KEY);
- if (database == null)
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("error.database.missing"));
- else {
- user = getUser(database, username);
- if ((user != null) && !user.getPassword().equals(password))
- user = null;
- if (user == null)
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("error.password.mismatch"));
- }
-
- // Report any errors we have discovered back to the original form
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ // Extract attributes we will need
+ User user = null;
+
+ // Validate the request parameters specified by the user
+ ActionErrors errors = new ActionErrors();
+ String username = (String) PropertyUtils.getSimpleProperty(form,
"username");
+ String password = (String) PropertyUtils.getSimpleProperty(form,
"password");
+ UserDatabase database =
+ (UserDatabase) servlet.getServletContext().getAttribute(
+ Constants.DATABASE_KEY);
+
+ if (database == null)
+ errors.add(
+ ActionErrors.GLOBAL_ERROR,
+ new ActionMessage("error.database.missing"));
+ else {
+ user = getUser(database, username);
+ if ((user != null) && !user.getPassword().equals(password))
+ user = null;
+ if (user == null)
+ errors.add(
+ ActionErrors.GLOBAL_ERROR,
+ new ActionMessage("error.password.mismatch"));
+ }
+
+ // Report any errors we have discovered back to the original form
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
return (mapping.getInputForward());
- }
+ }
- // Save our logged-in user in the session
- HttpSession session = request.getSession();
- session.setAttribute(Constants.USER_KEY, user);
+ // Save our logged-in user in the session
+ HttpSession session = request.getSession();
+ session.setAttribute(Constants.USER_KEY, user);
if (log.isDebugEnabled()) {
- log.debug("LogonAction: User '" + user.getUsername() +
- "' logged on in session " + session.getId());
+ log.debug(
+ "LogonAction: User '"
+ + user.getUsername()
+ + "' logged on in session "
+ + session.getId());
}
// Remove the obsolete form bean
- if (mapping.getAttribute() != null) {
+ if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
- // Forward control to the specified success URI
- return (mapping.findForward("success"));
+ // Forward control to the specified success URI
+ return (mapping.findForward("success"));
}
-
// ------------------------------------------------------ Protected Methods
-
/**
* Look up the user, throwing an exception to simulate business logic
* rule exceptions.
@@ -204,6 +197,5 @@
return ((User) database.findUser(username));
}
-
}
1.8 +34 -43
jakarta-struts/src/example/org/apache/struts/webapp/example/LogoffAction.java
Index: LogoffAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/LogoffAction.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LogoffAction.java 11 Jan 2003 03:08:23 -0000 1.7
+++ LogoffAction.java 16 Aug 2003 18:29:09 -0000 1.8
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,22 +59,18 @@
*
*/
-
package org.apache.struts.webapp.example;
-
-import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.util.MessageResources;
-
/**
* Implementation of <strong>Action</strong> that processes a
@@ -83,23 +79,17 @@
* @author Craig R. McClanahan
* @version $Revision$ $Date$
*/
-
public final class LogoffAction extends Action {
-
// ----------------------------------------------------- Instance Variables
-
/**
* The <code>Log</code> instance for this application.
*/
- private Log log =
- LogFactory.getLog("org.apache.struts.webapp.Example");
-
+ private Log log = LogFactory.getLog("org.apache.struts.webapp.Example");
// --------------------------------------------------------- Public Methods
-
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
@@ -114,38 +104,39 @@
*
* @exception Exception if business logic throws an exception
*/
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- // Extract attributes we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
- HttpSession session = request.getSession();
- User user = (User) session.getAttribute(Constants.USER_KEY);
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ // Extract attributes we will need
+ HttpSession session = request.getSession();
+ User user = (User) session.getAttribute(Constants.USER_KEY);
- // Process this user logoff
- if (user != null) {
+ // Process this user logoff
+ if (user != null) {
if (log.isDebugEnabled()) {
- log.debug("LogoffAction: User '" + user.getUsername() +
- "' logged off in session " + session.getId());
+ log.debug(
+ "LogoffAction: User '"
+ + user.getUsername()
+ + "' logged off in session "
+ + session.getId());
}
- } else {
+ } else {
if (log.isDebugEnabled()) {
- log.debug("LogoffActon: User logged off in session " +
- session.getId());
+ log.debug(
+ "LogoffActon: User logged off in session " + session.getId());
}
- }
- session.removeAttribute(Constants.SUBSCRIPTION_KEY);
- session.removeAttribute(Constants.USER_KEY);
- session.invalidate();
+ }
+ session.removeAttribute(Constants.SUBSCRIPTION_KEY);
+ session.removeAttribute(Constants.USER_KEY);
+ session.invalidate();
- // Forward control to the specified success URI
- return (mapping.findForward("success"));
+ // Forward control to the specified success URI
+ return (mapping.findForward("success"));
}
-
}
1.13 +4 -8
jakarta-struts/src/example/org/apache/struts/webapp/example/EditSubscriptionAction.java
Index: EditSubscriptionAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/EditSubscriptionAction.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- EditSubscriptionAction.java 3 Jul 2003 02:54:54 -0000 1.12
+++ EditSubscriptionAction.java 16 Aug 2003 18:29:09 -0000 1.13
@@ -62,7 +62,6 @@
package org.apache.struts.webapp.example;
import java.lang.reflect.InvocationTargetException;
-import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -76,7 +75,6 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.util.MessageResources;
/**
* Implementation of <strong>Action</strong> that populates an instance of
@@ -119,8 +117,6 @@
throws Exception {
// Extract attributes we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
HttpSession session = request.getSession();
String action = request.getParameter("action");
if (action == null) {
1.13 +4 -8
jakarta-struts/src/example/org/apache/struts/webapp/example/EditRegistrationAction.java
Index: EditRegistrationAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/EditRegistrationAction.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- EditRegistrationAction.java 3 Jul 2003 02:54:54 -0000 1.12
+++ EditRegistrationAction.java 16 Aug 2003 18:29:09 -0000 1.13
@@ -62,7 +62,6 @@
package org.apache.struts.webapp.example;
import java.lang.reflect.InvocationTargetException;
-import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -76,7 +75,6 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.util.MessageResources;
/**
* Implementation of <strong>Action</strong> that populates an instance of
@@ -120,8 +118,6 @@
throws Exception {
// Extract attributes we will need
- Locale locale = getLocale(request);
- MessageResources messages = getResources(request);
HttpSession session = request.getSession();
String action = request.getParameter("action");
if (action == null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]