There is an opportunity to introduce Date Validation in the validate method of your Validator class so for example to look at the Unit Test for ValidationUtils called /test/org/springframework/validation/ValidationUtilsTest.java you will see the private inner interface called EmptyValidator with a validate method here
public void validate(Object obj, Errors errors) { //TestBean tb = (TestBean) obj; //1st off reject any/all whitespace character(s) embedded ValidationUtils.rejectIfEmpty(errors, "FieldName", "EMPTY", "You must enter a name!"); //VALIDATE your date here and if Date is invalid call rejectifEmpty ValidationUtils.rejectifEmpty(errors,"FieldName","INVALIDATE_DATE","Date is invalid!"); } assuming /WEB-INF/YourServlet-servlet.xml has a definition something like <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"><value>org/springframework/web/context/WEB-INF/test-messages</value></property> </bean> where the test.messages.properties would contain suitable message text such as INVALIDATE_DATE=The date you have entered is not properly formatted code2=message2 On the other hand if its ok to complete the validation from the jsp page you could just use the struts date validator tag as seen in http://localhost:8080/struts2-showcase-2.0.1/validation/showFieldValidatorsExamples.action e.g. <tr> <td class="tdLabel"><label for="submitFieldValidatorsExamples_dateValidatorField" class="label">Date Validator Field:</label></td> <td><input type="text" name="dateValidatorField" value="" id="submitFieldValidatorsExamples_dateValidatorField"/></td> </tr> Anyone else? M- --------------------------------------------------------------------------- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. --------------------------------------------------------------------------- Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. ----- Original Message ----- From: "Dariusz Wojtas" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Monday, January 01, 2007 12:02 PM Subject: Re: [S2] Strange problem with Date handling >I am using Spring 2 but I do not define actions in Spring. > I use Spring to manage my services and security (acegi). > As I understand this way the actions are created the 'traditional' > way, and only some setters are later autowired - in this case by name. > My date property does not match any spring service, not even close ... > Do I still have to set the scope somewhere? > > I only set some props in my struts.properties: > struts.devMode=true > struts.enable.DynamicMethodInvocation=false > struts.action.extension=action > struts.objectFactory=spring > struts.objectFactory.spring.autoWire=name > > > Best regards > Dariusz Wojtas > > > On 1/1/07, Musachy Barroso <[EMAIL PROTECTED]> wrote: >> I had a similar problem before, are you using Spring 2 with S2? If you >> are, remember to set scope="prototype" in applicationContext.xml for >> your action bean >> >> musachy >> Dariusz Wojtas wrote: >> > Now I am stuck with some other issue, something so strange that seems >> > to be irrational. >> > >> > I have an URL >> > /myAction.action?dataPierwszejRejestracji=2006-12-31 >> > that leads to an action with a Date property - dataPierwszejRejestracji >> > >> > I submit this URL in IE and Firefox - works. >> > I submit the same URL under Opera and it fails with long stacktrace on >> > the Tomcat console. >> > I repeated it several times. >> > >> > java.lang.NullPointerException >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:197) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:337) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) >> > >> > >> > com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:115) >> > >> > >> > com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:217) >> > >> > >> > com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216) >> > >> > >> > com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:217) >> > >> > >> > com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216) >> > >> > >> > com.opensymphony.xwork2.interceptor.ParametersInterceptor.intercept(ParametersInterceptor.java:154) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:217) >> > >> > >> > com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216) >> > >> > >> > com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:219) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:217) >> > >> > >> > com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455) >> > >> > >> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:216) >> > >> > [...] >> > >> > >> > Has anyone faced this problem? >> > It does not make sense to me, but that's how it behaves. >> > The date comes from dropdowndatetimepicker. >> > I have cut all other request properties to narrow the problem down, >> > and this is the property left. Without this param in URL the action >> > executes. >> > >> > Using Struts 2, >> > 2.0.3 snapshot from trunk. >> > >> > Regards >> > Dariusz Wojtas > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >