Revision: 1218
http://stripes.svn.sourceforge.net/stripes/?rev=1218&view=rev
Author: bengunter
Date: 2009-11-10 16:15:07 +0000 (Tue, 10 Nov 2009)
Log Message:
-----------
Fixed STS-726: Multiple submit buttons in first Wizard page cause multiple
events on second page. Submit inputs were being carried forward because they
appear in "fields present." To fix that, I'm ignoring parameters whose name is
an event name for the form's target ActionBean.
Modified Paths:
--------------
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
===================================================================
--- branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
2009-11-10 14:16:48 UTC (rev 1217)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/WizardFieldsTag.java
2009-11-10 16:15:07 UTC (rev 1218)
@@ -15,18 +15,23 @@
package net.sourceforge.stripes.tag;
import static
net.sourceforge.stripes.controller.StripesConstants.URL_KEY_FIELDS_PRESENT;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TryCatchFinally;
+
import net.sourceforge.stripes.action.ActionBean;
+import net.sourceforge.stripes.controller.ActionResolver;
import net.sourceforge.stripes.controller.StripesConstants;
+import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.exception.StripesJspException;
+import net.sourceforge.stripes.exception.StripesServletException;
import net.sourceforge.stripes.util.CryptoUtil;
import net.sourceforge.stripes.util.HtmlUtil;
-import javax.servlet.ServletRequest;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TryCatchFinally;
-import java.util.HashSet;
-import java.util.Set;
-
/**
* <p>Examines the request and include hidden fields for all parameters that
have do
* not have form fields in the current form. Will include multiple values for
@@ -72,6 +77,7 @@
excludes.add( StripesConstants.URL_KEY_SOURCE_PAGE );
excludes.add( StripesConstants.URL_KEY_FIELDS_PRESENT );
excludes.add( StripesConstants.URL_KEY_EVENT_NAME );
+ excludes.add( StripesConstants.URL_KEY_FLASH_SCOPE_ID );
// Use the submitted action bean to eliminate any event related
parameters
ServletRequest request = getPageContext().getRequest();
@@ -109,8 +115,9 @@
}
// Loop through the request parameters and output the values
+ Class<? extends ActionBean> actionBeanType =
form.getActionBeanClass();
for (String name : paramNames) {
- if (!excludes.contains(name)) {
+ if (!excludes.contains(name) && !isEventName(actionBeanType,
name)) {
hidden.setName(name);
try {
hidden.doStartTag();
@@ -149,4 +156,25 @@
/* Suppress anything, because otherwise this might mask any causal
exception. */
}
}
+
+ /**
+ * Returns true if {...@code name} is the name of an event handled by
{...@link ActionBean}s of type
+ * {...@code beanType}.
+ *
+ * @param beanType An {...@link ActionBean} class
+ * @param name The name to look up
+ */
+ protected boolean isEventName(Class<? extends ActionBean> beanType, String
name) {
+ if (beanType == null || name == null)
+ return false;
+
+ try {
+ ActionResolver actionResolver =
StripesFilter.getConfiguration().getActionResolver();
+ return actionResolver.getHandler(beanType, name) != null;
+ }
+ catch (StripesServletException e) {
+ // Ignore the exception and assume the name is not an event
+ return false;
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development