Hello Struts experts, The ActionForm setter method is not being called for request parameters whose names begin with an upper-case letter. For example, my HTTP request is of the form ?Foo=1 (i.e., the HTTP request parameter name is "Foo") and my ActionForm subclass has setFoo(String) method defined. The setFoo method is not being called. On the other hand, if my HTTP request is of the form ?foo=1 then the setter is being called. I have to convert an existing web application to use Struts, and the existing application has numerous HTTP request parameters whose names begin with an upper case-letter followed by lower-case letters. So, it is not very practical for all my HTTP request parameters named "Foo" to be renamed to "foo". Can someone please suggest a solution? Thank you.
Unfortunately your case does not have any good solution. There isnt any out of the box solution either. I suggest you try the following approach. 1) Create your own subclass of RequestProcessor (or of TilesRequestProcessor if you use it) 2) Override the processPopulate() method in RequestProcessor with your own implementation. This method is the one that populates the Form bean from request using RequestUtils and Commons BeanUtils. 3) Create your own subclass for RequestUtils and implement the populate() method. In that method, get the request parameter names, covnert the first char of the request parameter to lower case and then do exactly what that method is doing.
I know this isnt exactly an elegant solution. But at the end of the day it is all about trade-offs. This solution eliminates the need to change your entire application, unit test and then functional test, not to mention the dollars needed for such an elaborate process. This solution should work without a hitch. Try it out. Also when you are done, could you please share your experiences in this forum? Thanks, Srikanth Shenoy Author: Struts Survival Guide - Basics to Best Practices