I've got accessor/mutators on my action for an integer ID parameter like this: NewUserAction { int _userGroupId = -1; // execute, validate, other methods setUserGroupId( int id ) { this._userGroupId = id; } getUserGroupId() { return _userGroupId; } }
But when I access this action with invalid / fuzz-test parameters like "/newuser.action?userGroupId=ASDF" I get this warning: 2012-03-15 10:34:34,741 WARN [com.opensymphony.xwork2.ognl.OgnlValueStack] (http-0.0.0.0-8080-1) Error setting expression 'userGroupId' with value '[Ljava.lang.String;@1ed15b50' ognl.MethodFailedException: Method "setUserGroupId" failed for object com.example.rgm.NewUser@4eeec90c [java.lang.NoSuchMethodException: com.example.rgm.NewUser.setUserGroupId([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1292) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1481) This would be OK, provided that my result saw the parameter's initial value of -1, however it seems that the FreeMarker Result that I'm using actually gets the "userGroupId" parameter as this invalid value. I expect that it would call NewUser.getUserGroupId() instead of using a temporary (invalid!) value from the ValueStack. Is there an XWork configuration parameter that avoids polluting the ValueStack after this type of exception, or do I have to write all my templates in such a way that I can't rely on integer types? When returning the ERROR result, Freemarker template processing is choking on this line: view-usergroup-error.ftl: <#-- A user group was specified, show information about the chosen group if it's valid. --> <#if (userGroupId >= -1)> .... freemarker.template.TemplateException: The only legal comparisons are between two numbers, two strings, or two dates. Left hand operand is a freemarker.ext.beans.StringModel Right hand operand is a freemarker.template.SimpleNumber --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org