Seems that it does not matter what the expression is? For me it occurs when I test for year > someConstant and whenever the year is not present I get this error. Year is of type Integer and validator is written like this:
<field name="year"> <field-validator type="fieldexpression"> <param name="expression">year > 1950</param> <message>year is ${year}?</message> </field-validator> </field> > What's the expression you're applying to the field? I'll see if I can > figure out what the issue is... > > > -----Original Message----- > > From: Taavi Tiirik [mailto:[EMAIL PROTECTED] > > Sent: Sunday, November 23, 2003 12:08 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [OS-webwork] validator for the optional int field > > > > > > > > > This is the problem of empty form fields causing type > > conversion field > > > errors that I fixed last night... Try the latest > > > > Excellent. Thanks! > > > > Now there is still this null pointer exception that happens > > if I use validator of type fieldexpression and if the field > > is left blank i.e. when I call validationtest.action?year= > > > > java.lang.NullPointerException > > at ognl.OgnlOps.doubleValue(OgnlOps.java:97) > > at ognl.OgnlOps.greater(OgnlOps.java:395) > > at ognl.ASTGreater.getValueBody(ASTGreater.java:51) > > at ognl.SimpleNode.getValue(SimpleNode.java:167) > > at ognl.Ognl.getValue(Ognl.java:335) > > at ognl.Ognl.getValue(Ognl.java:310) > > at > > com.opensymphony.xwork.util.OgnlValueStack.findValue(OgnlValue > > Stack.java:92) > > at > > com.opensymphony.xwork.validator.validators.ValidatorSupport.g > > etFieldValue(V > > alidatorSupport.java:90) > > at > > com.opensymphony.xwork.validator.validators.FieldExpressionVal > > idator.validat > > e(FieldExpressionValidator.java:37) > > at > > com.opensymphony.xwork.validator.ActionValidatorManager.valida > > te(ActionValid > > atorManager.java:69) > > at > > com.opensymphony.xwork.validator.ActionValidatorManager.valida > > te(ActionValid > > atorManager.java:55) > > at > > com.opensymphony.xwork.validator.ValidationInterceptor.before( > > ValidationInte > > rceptor.java:36) > > at > > com.opensymphony.xwork.interceptor.AroundInterceptor.intercept > > (AroundInterce > > ptor.java:36) > > at > > com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA > > ctionInvocatio > > n.java:169) > > at > > com.opensymphony.xwork.interceptor.AroundInterceptor.intercept > > (AroundInterce > > ptor.java:37) > > at > > com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA > > ctionInvocatio > > n.java:169) > > at > > com.opensymphony.xwork.interceptor.AroundInterceptor.intercept > > (AroundInterce > > ptor.java:37) > > at > > com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA > > ctionInvocatio > > n.java:169) > > at > > com.opensymphony.xwork.interceptor.AroundInterceptor.intercept > > (AroundInterce > > ptor.java:37) > > at > > com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA > > ctionInvocatio > > n.java:169) > > at > > com.opensymphony.xwork.interceptor.TimerInterceptor.intercept( > > TimerIntercept > > or.java:62) > > at > > com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA > > ctionInvocatio > > n.java:169) > > at > > com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActio > > nProxy.java:11 > > 6) > > at > > com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceA > > ction(ServletD > > ispatcher.java:182) > > at > > com.opensymphony.webwork.dispatcher.ServletDispatcher.service( > > ServletDispatc > > her.java:162) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > at > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilt > > er(Application > > FilterChain.java:247) > > at > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli > > cationFilterCh > > ain.java:193) > > at > > com.opensymphony.webwork.lifecycle.RequestLifecycleFilter.doFi > > lter(RequestLi > > fecycleFilter.java:62) > > at > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilt > > er(Application > > FilterChain.java:213) > > at > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli > > cationFilterCh > > ain.java:193) > > at > > cmw.filter.SetCharacterEncoding.doFilter(SetCharacterEncoding. > > java:169) > > at > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilt > > er(Application > > FilterChain.java:213) > > at > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli > > cationFilterCh > > ain.java:193) > > at cmw.filter.Persistence.doFilter(Persistence.java:70) > > at > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilt > > er(Application > > FilterChain.java:213) > > at > > org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli > > cationFilterCh > > ain.java:193) > > at > > org.apache.catalina.core.StandardWrapperValve.invoke(StandardW > > rapperValve.ja > > va:256) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:643) > > at > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipel > > ine.java:480) > > at > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > > at > > org.apache.catalina.core.StandardContextValve.invoke(StandardC > > ontextValve.ja > > va:191) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:643) > > at > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipel > > ine.java:480) > > at > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > > at > > org.apache.catalina.core.StandardContext.invoke(StandardContex > > t.java:2416) > > at > > org.apache.catalina.core.StandardHostValve.invoke(StandardHost > > Valve.java:180 > > ) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:643) > > at > > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDi > > spatcherValve. > > java:171) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:641) > > at > > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReport > > Valve.java:172 > > ) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:641) > > at > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipel > > ine.java:480) > > at > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > > at > > org.apache.catalina.core.StandardEngineValve.invoke(StandardEn > > gineValve.java > > :174) > > at > > org.apache.catalina.core.StandardPipeline$StandardPipelineValv > > eContext.invok > > eNext(StandardPipeline.java:643) > > at > > org.apache.catalina.core.StandardPipeline.invoke(StandardPipel > > ine.java:480) > > at > > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) > > at > > org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter. > > java:223) > > at > > org.apache.coyote.http11.Http11Processor.process(Http11Process > > or.java:601) > > at > > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandle > > r.processConne > > ction(Http11Protocol.java:392) > > at > > org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoi > > nt.java:565) > > at > > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run( > > ThreadPool.jav > > a:619) > > at java.lang.Thread.run(Thread.java:536) > > > > > > > > > > > > > > > -----Original Message----- > > > > From: Taavi Tiirik [mailto:[EMAIL PROTECTED] > > > > Sent: Sunday, November 23, 2003 10:15 AM > > > > To: [EMAIL PROTECTED] > > > > Subject: Re: [OS-webwork] validator for the optional int field > > > > > > > > > > > > > > > > I am using Integer instead of int now but whenever > > > > the input field is left blank I am still getting this > > Invalid field > > > > value for field "year" message. > > > > > > > > So my results so far are like this: > > > > > > > > these behave as expected: > > > > validationtest.action > > > > validationtest.action?year=12312313 > > > > > > > > this gives "Invalid field value for field "year" message: > > > > validationtest.action?year= > > > > > > > > I feel that it should not give that error. Removing > > > > "year=" from url is not an option because this kind > > > > of url is what we get if there is an input form field > > > > that is left blank. > > > > > > > > So, what to you think what should be the ww2 way > > > > of validating this kind of field? > > > > > > > > best wishes, > > > > Taavi > > > > > > > > > > > > ----- Original Message ----- > > > > From: "Jason Carreira" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Sunday, November 23, 2003 4:15 PM > > > > Subject: RE: [OS-webwork] validator for the optional int field > > > > > > > > > > > > > Did you try the IntRangeFieldValidator? It doesn't require > > > > a value... > > > > > Actually, if you have a primitive int, it will always get a > > > > value and > > > > > validate it... If it's an Integer you can have a null > > > > value, in which > > > > > case it would ignore it. > > > > > > > > > > > -----Original Message----- > > > > > > From: Taavi Tiirik [mailto:[EMAIL PROTECTED] > > > > > > Sent: Sunday, November 23, 2003 8:48 AM > > > > > > To: [EMAIL PROTECTED] > > > > > > Subject: Re: [OS-webwork] validator for the optional int field > > > > > > > > > > > > > > > > > > Sorry for not being clear ") > > > > > > > > > > > > I would like to specify field error message, if the field is > > > > > > filled with a value but this value is outside of some > > > > min-max range. > > > > > > > > > > > > And I would like to see this field pass this > > valiation rule if > > > > > > the field is left empty. > > > > > > > > > > > > So something like this comes to my mind: > > > > > > > > > > > > <field name="year"> > > > > > > <field-validator type="optional-int"> > > > > > > <param name="min">6</param> > > > > > > <param name="max">10</param> > > > > > > <message>bar must be between ${min} and ${max}, > > current value > > > > > > is ${bar}.</message> > > > > > > </field-validator> > > > > > > </field> > > > > > > > > > > > > > > > > > > > What do you want to validate about that field? > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Taavi Tiirik [mailto:[EMAIL PROTECTED] > > > > > > > > Sent: Sunday, November 23, 2003 8:04 AM > > > > > > > > To: [EMAIL PROTECTED] > > > > > > > > Subject: [OS-webwork] validator for the optional int field > > > > > > > > > > > > > > > > > > > > > > > > How should I write a validator for the optional > > int field in > > > > > > > > ww2? > > > > > > > > > > > > > > > > I have getter and setter in my action: > > > > > > > > public int getYear(){ return year; } > > > > > > > > public void setYear( int year ){ this.year = year; } > > > > > > > > > > > > > > > > input field is defined like this: > > > > > > > > #tag( TextField "label='year'" "name='year'" "value=year" > > > > > > "size='5'" > > > > > > > > ) > > > > > > > > > > > > > > > > What should I put into action-validation.xml? > > > > > > > > > > > > > > > > Taavi > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > > > This SF.net email is sponsored by: SF.net Giveback > > > > Program. Does > > > > > > > > SourceForge.net help you be more productive? Does it > > > > help you > > > > > > > > create better code? SHARE THE LOVE, and help us help > > > > YOU! Click > > > > > > > > Here: http://sourceforge.net/donate/ > > > > > > > > _______________________________________________ > > > > > > > > Opensymphony-webwork mailing list > > > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > > > This SF.net email is sponsored by: SF.net Giveback Program. > > > > > > > Does SourceForge.net help you be more productive? Does it > > > > > > > help > > > > > > you create > > > > > > > better code? SHARE THE LOVE, and help us help YOU! Click > > > > > > > Here: http://sourceforge.net/donate/ > > > > > > > _______________________________________________ > > > > > > > Opensymphony-webwork mailing list > > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webw > > > ork > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > This SF.net email is sponsored by: SF.net Giveback > > Program. Does > > > > > SourceForge.net help you be more productive? Does it help you > > > > > create better code? SHARE THE LOVE, and help us help > > YOU! Click > > > > > Here: http://sourceforge.net/donate/ > > > > > _______________________________________________ > > > > > Opensymphony-webwork mailing list > > > > > [EMAIL PROTECTED] > > > > > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.net email is sponsored by: SF.net Giveback Program. Does > > > > SourceForge.net help you be more productive? Does it help you > > > > create better code? SHARE THE LOVE, and help us help YOU! Click > > > > Here: http://sourceforge.net/donate/ > > > > _______________________________________________ > > > > Opensymphony-webwork mailing list > > > > [EMAIL PROTECTED] > > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: SF.net Giveback Program. Does > > > SourceForge.net help you be more productive? Does it help > > you create > > > better code? SHARE THE LOVE, and help us help YOU! Click Here: > > > http://sourceforge.net/donate/ > > > _______________________________________________ > > > Opensymphony-webwork mailing list > > > [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: SF.net Giveback Program. Does > > > SourceForge.net help you be more productive? Does it help > > you create > > > better code? SHARE THE LOVE, and help us help YOU! Click Here: > > > http://sourceforge.net/donate/ > > > _______________________________________________ > > > Opensymphony-webwork mailing list > > > [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us > > help YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Opensymphony-webwork mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork