views:

1045

answers:

1

i am using strut2.1.6 with tomcat 5.5

i have a Date field createDate in my PasswordHistory Bean, and corresponding date component on my "search.jsp" this field is optional - no validation required .

if i submit the form i am get the follwoing error on console ognl.MethodFailedException: Method "setCreatedDate" failed for object com.security.data.PasswordHistory@d5b561 [java.lang.NoSuchMethodException: setCreatedDate([Ljava.lang.String;)] –

it looks that it is trying to convert the empty string to date, when it fails it tries to search the corresponding String argument method and if it converts the value to date successfully it calls the corresponding Date argument method – Muhammad Shahid

i want to avoid any conversion if the field is emtpy.

+1  A: 

Do you have struts.devMode = true in struts.xml? From the docs:

And thirdly, perhaps the setting which is less widely known, and therefore a source of much confusion: it will raise the level of debug or normally ignorable problems to errors. For example: when you submit a field which cannot be set on an action 'someUnknownField', it will normally be ignored. However, when you're in development mode, an exception will be thrown, telling you an invalid field was submitted. This is very useful for debugging or testing large forms, but can also be confusing if you're relying on parameters in your request that are not set on the action, but which you are using directly in your view layer (warning: bad practice, you should always validate input from the web).

http://struts.apache.org/2.1.6/docs/devmode.html

Nate