Commits

Anonymous committed cbb01b0

WW-3154 RepopulateConversionErrorFieldValidatorSupport logs a warning when repopulating fields without conversion errors

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@2036e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

core/src/main/java/com/opensymphony/xwork2/validator/validators/RepopulateConversionErrorFieldValidatorSupport.java

 		
 		String fieldName = getFieldName();
 		String fullFieldName = getValidatorContext().getFullFieldName(fieldName);
-		Object value = conversionErrors.get(fullFieldName);
-		
-		final Map<Object, Object> fakeParams = new LinkedHashMap<Object, Object>();
-		boolean doExprOverride = false;
-		
-		if (value instanceof String[]) {
-			// take the first element, if possible
-			String[] tmpValue = (String[]) value;
-			if (tmpValue != null && (tmpValue.length > 0) ) {
-				doExprOverride = true;
-				fakeParams.put(fullFieldName, "'"+tmpValue[0]+"'");
-			}
-			else {
-				LOG.warn("value is an empty array of String or with first element in it as null ["+value+"], will not repopulate conversion error ");
-			}
-		}
-		else if (value instanceof String) {
-			String tmpValue = (String) value;
-			doExprOverride = true;
-			fakeParams.put(fullFieldName, "'"+tmpValue+"'");
-		}
-		else {
-			// opps... it should be 
-			LOG.warn("conversion error value is not a String or array of String but instead is ["+value+"], will not repopulate conversion error");
-		}
-		
-		if (doExprOverride) {
-			invocation.addPreResultListener(new PreResultListener() {
-				public void beforeResult(ActionInvocation invocation, String resultCode) {
-					ValueStack stack = ActionContext.getContext().getValueStack();
-					stack.setExprOverrides(fakeParams);
-				}
-			});
-		}
+        if (conversionErrors.containsKey(fullFieldName)) {
+            Object value = conversionErrors.get(fullFieldName);
+
+            final Map<Object, Object> fakeParams = new LinkedHashMap<Object, Object>();
+            boolean doExprOverride = false;
+
+            if (value instanceof String[]) {
+                // take the first element, if possible
+                String[] tmpValue = (String[]) value;
+                if (tmpValue != null && (tmpValue.length > 0)) {
+                    doExprOverride = true;
+                    fakeParams.put(fullFieldName, "'" + tmpValue[0] + "'");
+                } else {
+                    LOG.warn("value is an empty array of String or with first element in it as null [" + value + "], will not repopulate conversion error ");
+                }
+            } else if (value instanceof String) {
+                String tmpValue = (String) value;
+                doExprOverride = true;
+                fakeParams.put(fullFieldName, "'" + tmpValue + "'");
+            } else {
+                // opps... it should be 
+                LOG.warn("conversion error value is not a String or array of String but instead is [" + value + "], will not repopulate conversion error");
+            }
+
+            if (doExprOverride) {
+                invocation.addPreResultListener(new PreResultListener() {
+                    public void beforeResult(ActionInvocation invocation, String resultCode) {
+                        ValueStack stack = ActionContext.getContext().getValueStack();
+                        stack.setExprOverrides(fakeParams);
+                    }
+                });
+            }
+        }
 	}
 	
 	protected abstract void doValidate(Object object) throws ValidationException;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.