I'm trying to use the OGNL support in Struts 2.0.14 to set some parameter values in the jFreeChart plugin's chart result type. But I keep getting errors because it appears to be expecting all properties to be Strings, even if the OGNL doesn't return a String. I'm using:
<action name="chart-frame-selection-rate" class="com.vsp.global.controller.ChartFrameSelectionRateAction"> <param name="role">user</param> <result type="chart"> <param name="width">$...@com.example.config@getInt("reports","frameSelectionRate.width")}</param> <param name="height">$...@com.example.config@getInt("reports","frameSelectionRate.height")}</param> </result> <result name="failure" type="httpheader">404</result> </action> Where where com.example.Config.getInt is defined as public int getInt (String domain,String key); But when struts tries to instantiate the result I get: [2010-04-01 10:46:57,785] ERROR {abcOu3jlPU3Rf_9tFPSzs} DefaultActionInvocation.createResult: There was an exception while instantiating the result of type org.apache.struts2.dispatcher.ChartResult Caught OgnlException while setting property 'width' on type 'org.apache.struts2.dispatcher.ChartResult'. - Class: ognl.OgnlRuntime File: OgnlRuntime.java Method: callAppropriateMethod Line: 1206 - ognl/OgnlRuntime.java:1206:-1 at com.opensymphony.xwork2.util.OgnlUtil.internalSetProperty(OgnlUtil.java:367) at com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:76) . . . Caused by: java.lang.NoSuchMethodException: org.apache.struts2.dispatcher.ChartResult.setWidth(java.lang.String) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) Is there any way to make struts recognize that the value is an int, so it needs to call setWidth(int)? (*Chris*)