Commits

Anonymous committed 63e2f97

XW-386
- fix "XWork don't create result using Spring"
- commit this missed out file, cause if not it breaks compilation

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

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java

             String name = resultTypeElement.getAttribute("name");
             String className = resultTypeElement.getAttribute("class");
             String def = resultTypeElement.getAttribute("default");
+            
             Location loc = DomHelper.getLocationObject(resultTypeElement);
 
             Class clazz = verifyResultType(className, loc);
             if (clazz != null) {
-                ResultTypeConfig resultType = new ResultTypeConfig(name, clazz);
+            	String paramName = null;
+            	try {
+            		paramName = (String) clazz.getField("DEFAULT_PARAM").get(null);
+            	}
+            	catch(Throwable t) {
+            		// if we get here, the result type doesn't have a default param defined.
+            	}
+                ResultTypeConfig resultType = new ResultTypeConfig(name, className, paramName);
                 resultType.setLocation(DomHelper.getLocationObject(resultTypeElement));
 
                 Map params = XmlHelper.getParams(resultTypeElement);
                     throw new ConfigurationException("There is no result type defined for type '" + resultType + "' mapped with name '" + resultName + "'", resultElement);
                 }
 
-                Class resultClass = config.getClazz();
+                String resultClass = config.getClazz();
 
                 // invalid result type specified in result definition
                 if (resultClass == null) {
                     throw new ConfigurationException("Result type '" + resultType + "' is invalid");
                 }
 
-                Map resultParams = XmlHelper.getParams(resultElement);
+                Map<String, String> resultParams = XmlHelper.getParams(resultElement);
 
                 if (resultParams.size() == 0) // maybe we just have a body - therefore a default parameter
                 {
                     // if <result ...>something</result> then we add a parameter of 'something' as this is the most used result param
                     if ((resultElement.getChildNodes().getLength() == 1) && (resultElement.getChildNodes().item(0).getNodeType() == Node.TEXT_NODE))
                     {
-                        resultParams = new LinkedHashMap();
+                        resultParams = new LinkedHashMap<String, String>();
 
-                        try {
-                            String paramName = (String) resultClass.getField("DEFAULT_PARAM").get(null);
+                       	String paramName = config.getDefaultResultParam();
+                       	if (paramName != null) {
                             String paramValue = resultElement.getChildNodes().item(0).getNodeValue();
                             if (paramValue != null) {
                                 paramValue = paramValue.trim();
                             }
                             resultParams.put(paramName, paramValue);
-                        } catch (Throwable t) {
-                        }
+                       	}
+                       	else {
+                       		LOG.warn("no default parameter defined for result of type "+config.getName());
+                       	}
                     }
                 }