From 2e35d3cfb3a87ab1273122530902138c20acef52 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Tue, 29 Apr 2008 03:44:07 +0000 Subject: [PATCH] using new web utils method in 2.5.4 --- .../support/ActionExecutingViewFactory.java | 50 +------------------ .../webflow/mvc/view/AbstractMvcView.java | 46 +---------------- 2 files changed, 4 insertions(+), 92 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionExecutingViewFactory.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionExecutingViewFactory.java index 8b238eb7..7bb6b124 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionExecutingViewFactory.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/support/ActionExecutingViewFactory.java @@ -15,9 +15,7 @@ */ package org.springframework.webflow.engine.support; -import java.util.Iterator; - -import org.springframework.webflow.core.collection.ParameterMap; +import org.springframework.web.util.WebUtils; import org.springframework.webflow.engine.ActionExecutor; import org.springframework.webflow.execution.Action; import org.springframework.webflow.execution.Event; @@ -87,51 +85,7 @@ public class ActionExecutingViewFactory implements ViewFactory { } private void determineEventId(RequestContext context) { - eventId = findParameter("_eventId", context.getRequestParameters()); + eventId = WebUtils.findParameterValue(context.getRequestParameters().asMap(), "_eventId"); } - - /** - * Obtain a named parameter from the request parameters. This method will try to obtain a parameter value using - * the following algorithm: - *
    - *
  1. Try to get the parameter value using just the given logical name. This handles parameters of the - * form logicalName = value. For normal parameters, e.g. submitted using a hidden HTML form field, - * this will return the requested value.
  2. - *
  3. Try to obtain the parameter value from the parameter name, where the parameter name in the request is of - * the form logicalName_value = xyz with "_" being the configured delimiter. This deals with - * parameter values submitted using an HTML form submit button.
  4. - *
  5. If the value obtained in the previous step has a ".x" or ".y" suffix, remove that. This handles cases - * where the value was submitted using an HTML form image button. In this case the parameter in the request - * would actually be of the form logicalName_value.x = 123.
  6. - *
- * @param logicalParameterName the logical name of the request parameter - * @param parameters the available parameter map - * @return the value of the parameter, or null if the parameter does not exist in given request - */ - private String findParameter(String logicalParameterName, ParameterMap parameters) { - // first try to get it as a normal name=value parameter - String value = parameters.get(logicalParameterName); - if (value != null) { - return value; - } - // if no value yet, try to get it as a name_value=xyz parameter - String prefix = logicalParameterName + "_"; - Iterator paramNames = parameters.asMap().keySet().iterator(); - while (paramNames.hasNext()) { - String paramName = (String) paramNames.next(); - if (paramName.startsWith(prefix)) { - String strValue = paramName.substring(prefix.length()); - // support images buttons, which would submit parameters as - // name_value.x=123 - if (strValue.endsWith(".x") || strValue.endsWith(".y")) { - strValue = strValue.substring(0, strValue.length() - 2); - } - return strValue; - } - } - // we couldn't find the parameter value - return null; - } - } } \ No newline at end of file diff --git a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java index 37f86d67..694b460b 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/mvc/view/AbstractMvcView.java @@ -46,6 +46,7 @@ import org.springframework.util.ReflectionUtils; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.validation.Errors; +import org.springframework.web.util.WebUtils; import org.springframework.webflow.core.collection.ParameterMap; import org.springframework.webflow.definition.TransitionDefinition; import org.springframework.webflow.definition.TransitionableStateDefinition; @@ -301,50 +302,7 @@ public abstract class AbstractMvcView implements View { } private void determineEventId(RequestContext context) { - eventId = findParameter("_eventId", context.getRequestParameters()); - } - - /** - * Obtain a named parameter from the request parameters. This method will try to obtain a parameter value using the - * following algorithm: - *
    - *
  1. Try to get the parameter value using just the given logical name. This handles parameters of the - * form logicalName = value. For normal parameters, e.g. submitted using a hidden HTML form field, this - * will return the requested value.
  2. - *
  3. Try to obtain the parameter value from the parameter name, where the parameter name in the request is of the - * form logicalName_value = xyz with "_" being the configured delimiter. This deals with parameter values - * submitted using an HTML form submit button.
  4. - *
  5. If the value obtained in the previous step has a ".x" or ".y" suffix, remove that. This handles cases where - * the value was submitted using an HTML form image button. In this case the parameter in the request would actually - * be of the form logicalName_value.x = 123.
  6. - *
- * @param logicalParameterName the logical name of the request parameter - * @param parameters the available parameter map - * @return the value of the parameter, or null if the parameter does not exist in given request - */ - private String findParameter(String logicalParameterName, ParameterMap parameters) { - // first try to get it as a normal name=value parameter - String value = parameters.get(logicalParameterName); - if (value != null) { - return value; - } - // if no value yet, try to get it as a name_value=xyz parameter - String prefix = logicalParameterName + "_"; - Iterator paramNames = parameters.asMap().keySet().iterator(); - while (paramNames.hasNext()) { - String paramName = (String) paramNames.next(); - if (paramName.startsWith(prefix)) { - String strValue = paramName.substring(prefix.length()); - // support images buttons, which would submit parameters as - // name_value.x=123 - if (strValue.endsWith(".x") || strValue.endsWith(".y")) { - strValue = strValue.substring(0, strValue.length() - 2); - } - return strValue; - } - } - // we couldn't find the parameter value - return null; + eventId = WebUtils.findParameterValue(context.getRequestParameters().asMap(), "_eventId"); } private static class PropertyNotFoundError implements MappingResultsCriteria {