craigmcc 2002/06/15 22:32:50
Modified: src/example/org/apache/struts/webapp/example
SaveRegistrationAction.java
SaveSubscriptionAction.java
src/share/org/apache/struts/util RequestUtils.java
Log:
When determining whether we can recycle a form bean instance,
accept subclasses of the specified form bean type instead of
performing an exact match.
PR: Bugzilla #9471
Submitted by: Curt Johnson <cjohnson at arrayservices.com>
Revision Changes Path
1.8 +9 -5
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SaveRegistrationAction.java 11 Mar 2002 06:13:13 -0000 1.7
+++ SaveRegistrationAction.java 16 Jun 2002 05:32:50 -0000 1.8
@@ -220,7 +220,6 @@
(regform.getPassword().length() < 1)) {
user.setPassword(oldPassword);
}
- database.save();
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null) {
@@ -233,6 +232,11 @@
throw new ServletException("Subscription.populate", t);
}
+ try {
+ database.save();
+ } catch (Exception e) {
+ log.error("Database save", e);
+ }
// Log the user in if appropriate
if ("Create".equals(action)) {
1.8 +21 -6
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SaveSubscriptionAction.java 11 Mar 2002 06:13:13 -0000 1.7
+++ SaveSubscriptionAction.java 16 Jun 2002 05:32:50 -0000 1.8
@@ -188,8 +188,15 @@
user.getUsername() + "'");
}
user.removeSubscription(subscription);
- user.getDatabase().save();
session.removeAttribute(Constants.SUBSCRIPTION_KEY);
+ try {
+ UserDatabase database = (UserDatabase)
+ servlet.getServletContext().
+ getAttribute(Constants.DATABASE_KEY);
+ database.save();
+ } catch (Exception e) {
+ log.error("Database save", e);
+ }
return (mapping.findForward("success"));
}
@@ -201,7 +208,6 @@
}
try {
PropertyUtils.copyProperties(subscription, subform);
- user.getDatabase().save();
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null)
@@ -211,6 +217,15 @@
} catch (Throwable t) {
log.error("Subscription.populate", t);
throw new ServletException("Subscription.populate", t);
+ }
+
+ try {
+ 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
1.36 +19 -13
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
Index: RequestUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- RequestUtils.java 8 Apr 2002 04:30:41 -0000 1.35
+++ RequestUtils.java 16 Jun 2002 05:32:50 -0000 1.36
@@ -582,16 +582,22 @@
return (instance);
}
} else {
- String className =
- instance.getClass().getName();
- if (className.equals(config.getType())) {
- if (LOG.isDebugEnabled()) {
- LOG.debug
- (" Recycling existing ActionForm instance " +
- "of class '" + className + "'");
- LOG.trace(" --> " + instance);
+ try {
+ if (Class.forName(config.getType()).isInstance(instance)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug
+ (" Recycling existing ActionForm instance " +
+ "of class '" + instance.getClass().getName()
+ + "'");
+ LOG.trace(" --> " + instance);
+ }
+ return (instance);
}
return (instance);
+ } catch (Throwable t) {
+ LOG.error(servlet.getInternal().getMessage
+ ("formBean", config.getName()), t);
+ return (null);
}
}
}
@@ -624,7 +630,7 @@
}
} catch (Throwable t) {
LOG.error(servlet.getInternal().getMessage
- ("formBean", config.getType()), t);
+ ("formBean", config.getName()), t);
return (null);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>