From: Ken K. <kk...@ig...> - 2002-06-02 03:03:47
|
Does anyone use this w/ Turbine/Velocity? When I open: localhost:8080/formproc-example I get the index.jsp except the Age fields contains 0. Is this intentional? If I fill in all fields, process.jsp presents the User object just fine. If I leave either password field blank, I get a stack trace: javax.servlet.ServletException: exception from JPython: Traceback (innermost last): File "", line 5, in ? TypeError: len() of unsized object at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp l.java:442) at org.apache.jsp._0002fprocess_jsp._jspService(_0002fprocess_jsp.java:166) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:200) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:453) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) If I type the wrong date format, the date field is blanked when the former is redisplayed. Is this intentional? Thx. -Ken |
From: Anthony E. <me...@an...> - 2002-06-02 12:45:08
|
> -----Original Message----- > From: for...@li... > [mailto:for...@li...] On > Behalf Of Ken Keller > Sent: Saturday, June 01, 2002 11:01 PM > To: for...@li... > Subject: [FormProc-developer] does anyone use this w/ > Turbine/Velocity? > > > Does anyone use this w/ Turbine/Velocity? > > When I open: > localhost:8080/formproc-example > > I get the index.jsp except the Age fields contains 0. Is this > intentional? It is just a side-effect of the fact that User.age field does not have an initial value. You could probably change it to type Integer and then check for null and display nothing if the value is null. > If I fill in all fields, process.jsp presents the User object > just fine. > > If I leave either password field blank, I get a stack trace: > javax.servlet.ServletException: exception from JPython: > Traceback (innermost > last): > File "", line 5, in ? > TypeError: len() of unsized object > > at > org.apache.jasper.runtime.PageContextImpl.handlePageException( > PageContextImp > l.java:442) > at > org.apache.jsp._0002fprocess_jsp._jspService(_0002fprocess_jsp > .java:166) > at > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > org.apache.jasper.servlet.JspServlet$JspServletWrapper.service > (JspServlet.ja > va:200) > at > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet > .java:379) > at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:453) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) This has been fixed in the CVS (it was a problem in PasswordValidator.py). > > If I type the wrong date format, the date field is blanked > when the former is redisplayed. Is this intentional? Right now the converter behavior is to throw an exception if the date is formatted incorrectly. If an exception is thrown then the value is never saved to the object. BTW: Have you tried the FormProcService which is a TurbineService implementation yet? I haven't tested it yet so I would be interested if anyone who does use Turbine on a regular basis would take a look at it. It is in the CVS in the turbine-service module. Sincerely, Anthony Eden |
From: Ken K. <kk...@ig...> - 2002-06-02 16:24:02
|
First let me say that at ign.com we're been using our own validation framework for over a year. Now I'm surveying what others have done. Your framework looks very well done. * * * If you leave the age field blank, you get: java.lang.NullPointerException at org.formproc.example.IsIntRule.validate(Unknown Source) at org.formproc.validation.RuleValidator.validate(Unknown Source) at org.formproc.validation.ValidatorGroup.validate(Unknown Source) at org.formproc.Form.validate(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.Form.process(Unknown Source) at org.formproc.servlet.HttpForm.process(Unknown Source) <shared-validator name="age"> <validator type="group"> <validator type="rule"> <rule>org.formproc.example.IsIntRule</rule> <error>Valid number required</error> <error lang="fr">L'âge valide a exigé.</error> </validator> <validator type="expression"> <pattern>[1-9][0-9]*</pattern> <error>Age must be 1 or greater</error> </validator> </validator> </shared-validator> Should the expression validator be listed before the IsIntRule? Since the age field isn't marked required, why do the validators get applied when the field is blank? * * * In the example, you decided to hold the form's state in a User in the session. This doesn't seem correct to me. It seems preferable to redisplay the invalid form w/ the invalid strings. After all, you're validating from the HttpRequest via HttpForm. So would the code be something like this? Age: <% if (! elementResults.isValid("age")) { >% <input type="text" name="age" value="<%= req.getParameter("age") %>"> <font color="#ff0000"> <% else { %> <input type="text" name="age" value="<%= user.getAge() %>"> <font> <% } %> <%= form.getMessage("age", locale) %> </font> * * * formManager.configure(form); To avoid repeated parsing of the XML, should the formManager be instantiated once per app? * * * > BTW: Have you tried the FormProcService which is a TurbineService > implementation yet? I haven't tested it yet so I would be interested if > anyone who does use Turbine on a regular basis would take a look at it. > It is in the CVS in the turbine-service module. Turbine 2.1? Did you program this service? Is there any documentation? Thx. -Ken |
From: Anthony E. <me...@an...> - 2002-06-02 18:32:16
|
> -----Original Message----- > From: for...@li...=20 > [mailto:for...@li...] On=20 > Behalf Of Ken Keller > Sent: Sunday, June 02, 2002 12:22 PM > To: Anthony Eden; FormProc Developer List > Subject: [FormProc-developer] I haven't tested FormProcService yet >=20 >=20 > First let me say that at ign.com we're been using our own=20 > validation framework for over a year. Now I'm surveying what=20 > others have done. Your framework looks very well done. Glad you like it. It is good mostly because of the input I have received from others using it. >=20 > * * * >=20 > If you leave the age field blank, you get: >=20 > java.lang.NullPointerException > at org.formproc.example.IsIntRule.validate(Unknown Source) > at=20 > org.formproc.validation.RuleValidator.validate(Unknown Source) > at=20 > org.formproc.validation.ValidatorGroup.validate(Unknown Source) > at org.formproc.Form.validate(Unknown Source) > at org.formproc.Form.process(Unknown Source) > at org.formproc.Form.process(Unknown Source) > at org.formproc.Form.process(Unknown Source) > at org.formproc.servlet.HttpForm.process(Unknown Source) Which FormProc version are you using? >=20 > <shared-validator name=3D"age"> > <validator type=3D"group"> > <validator type=3D"rule"> > <rule>org.formproc.example.IsIntRule</rule> > <error>Valid number required</error> > <error lang=3D"fr">L'=E2ge valide a exig=E9.</error> > </validator> > <validator type=3D"expression"> > <pattern>[1-9][0-9]*</pattern> > <error>Age must be 1 or greater</error> > </validator> > </validator> > </shared-validator> >=20 > Should the expression validator be listed before the IsIntRule? The IsIntRule isn't necessary, per se. I only included it in this context as a way to demonstrate how group validators work. > Since the age field isn't marked required, why do the=20 > validators get applied when the field is blank? It is required, even if the message doesn't say so. Validators are always applied on a field if the validator exists. If there is no validator for a field then a PassValidator will be used which just passes the value through as valid. >=20 > * * * >=20 > In the example, you decided to hold the form's state in a=20 > User in the session. This doesn't seem correct to me. It=20 > seems preferable to redisplay the invalid form w/ the invalid=20 > strings. After all, you're validating from the HttpRequest=20 > via HttpForm. So would the code be something like this? >=20 > Age: > <% if (! elementResults.isValid("age")) { >% > <input type=3D"text" name=3D"age" value=3D"<%=3D=20 > req.getParameter("age") %>"> <font color=3D"#ff0000"> <% else {=20 > %> <input type=3D"text" name=3D"age" value=3D"<%=3D user.getAge()=20 > %>"> <font> <% } %> <%=3D form.getMessage("age", locale) %> </font> You could design it that way. The only reason I hold it in the object in the session is because in my systems objects in the session are only saved when an explicit save() method (or something similar) is called. Thus the in-memory state is only for temporary storage. You could also store the results in a HashMap. Check out the org.formproc.store.MapStorer class. Eventually I will include another example which will use that as an example. You can also create a custom Storer to function however it makes sense for you. Another Storer which I am working on will store the data in an XML document. > * * * >=20 > formManager.configure(form); >=20 > To avoid repeated parsing of the XML, should the formManager=20 > be instantiated once per app? Yes. > * * * >=20 > > BTW: Have you tried the FormProcService which is a TurbineService=20 > > implementation yet? I haven't tested it yet so I would be=20 > interested=20 > > if anyone who does use Turbine on a regular basis would=20 > take a look at=20 > > it. It is in the CVS in the turbine-service module. >=20 > Turbine 2.1? Did you program this service? Is there any documentation? >=20 > Thx. -Ken I believe I wrote it against 2.2b2 API. It is actually in the FormProc CVS - there is no affiliation with Turbine. It is just something which I threw together quickly so it may not even work. The only documentation is in the code (JavaDoc). I would definitely classify it as "experimental". :-) Sincerely, Anthony Eden |
From: Ken K. <kk...@ig...> - 2002-06-02 22:32:49
|
I looked at your CVS. So the idea is to have Turbine create a TurbineFormProcService instance & call init() which creates a FormManager once. You call: HttpForm aForm = formProcSvc.createForm(name, target); The service binds the FormManager for you. Does this make the svc available to Velocity as $FormProc? Even if it did, I don't think it can be used from Velocity screens without either putting various collections into the Context such as: $formFieldResults $formFieldGroupResults $formFieldMessages or adding more methods such as: $form.getGroupErrorMessages() Am I missing something? -Ken |
From: Anthony E. <me...@an...> - 2002-06-02 23:03:04
|
> -----Original Message----- > From: for...@li... > [mailto:for...@li...] On > Behalf Of Ken Keller > Sent: Sunday, June 02, 2002 6:30 PM > To: Anthony Eden; FormProc Developer List > Subject: [FormProc-developer] FormProcService > > > I looked at your CVS. > > So the idea is to have Turbine create a > TurbineFormProcService instance & call init() which creates a > FormManager once. > > You call: > HttpForm aForm = formProcSvc.createForm(name, target); > The service binds the FormManager for you. > > Does this make the svc available to Velocity as $FormProc? No. I did not write the "pull" part of the service yet. I am not completely familiar with how Turbine works so a lot of this is new for me. Once I do I imagine I would like to be able to expose the Form object as $form (or perhaps have some way to name the form, i.e. $myForm1 or $myForm2...but perhaps that isn't necessary or even possible). > Even if it did, I don't think it can be used from Velocity > screens without either putting various collections into the > Context such as: $formFieldResults $formFieldGroupResults > $formFieldMessages or adding more methods such as: > $form.getGroupErrorMessages() > > Am I missing something? -Ken Well, if you have a Form object and you call form.process() with the HttpServletRequest then the results are in the FormResult object. However none of this is exposed in the context. Like I said up above I still need to work out the "pull" part of the service. Sincerely, Anthony Eden |
From: Ken K. <kk...@ig...> - 2002-06-02 19:37:06
|
I'm running 1.0b2. How can I get the behavior of optional fields, i.e., empty fields shouldn't be validated? -Ken |
From: Anthony E. <me...@an...> - 2002-06-02 22:55:10
|
I suppose it depends on which validator you are using. I must assume that the behavior you are looking for is: 1.) If field empty, return true as valid 2.) If field not empty, validate using assigned validators If that is the case, then you would have to put that logic in the validator (i.e. in a regular expression validator you would have to account for empty values). Perhaps it would be useful to be able to tag a field as optional? If you just wanted to have a value always ignored then you could just not assign a validator, but somehow I doubt this is your intention. Sincerely, Anthony Eden > -----Original Message----- > From: for...@li... > [mailto:for...@li...] On > Behalf Of Ken Keller > Sent: Sunday, June 02, 2002 3:35 PM > To: Anthony Eden; FormProc Developer List > Subject: [FormProc-developer] I'm running 1.0b2 > > > I'm running 1.0b2. > > How can I get the behavior of optional fields, i.e., empty > fields shouldn't be validated? -Ken > > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's > Conference August 25-28 in Las Vegas -- > http://devcon.sprintpcs.com/adp/index.cfm > > > _______________________________________________ > FormProc-developer mailing list > For...@li... > https://lists.sourceforge.net/lists/listinfo/formproc-developer > |
From: Ken K. <kk...@sn...> - 2002-06-02 23:19:22
|
> 1.) If field empty, return true as valid > 2.) If field not empty, validate using assigned validators > > If that is the case, then you would have to put that logic in the > validator (i.e. in a regular expression validator you would have to > account for empty values). Perhaps it would be useful to be able to tag > a field as optional? I think so. I don't want the converter to run on an empty field either. I also think it would be nice to have these ValidationResultMap methods: String getOriginalValue(name): Should only return null if name doesn't exist. Object getConvertedValue(name): Can return null. Object getConvertedOrOriginalValue(name): Return the original value if invalid--otherwise the converted one. String [] getGroupErrorMessages() String getErrorOrMessage(name): Return the message if valid--otherwise the error msg. Instead of having to deal with two ValidationResultMaps, it would be nice to have a wrapper object. Ken |
From: Anthony E. <me...@an...> - 2002-06-03 15:21:50
|
> -----Original Message----- > From: for...@li... > [mailto:for...@li...]On Behalf Of Ken > Keller > Sent: Sunday, June 02, 2002 7:17 PM > To: Anthony Eden; FormProc Developer List > Subject: [FormProc-developer] optional fields > > > > 1.) If field empty, return true as valid > > 2.) If field not empty, validate using assigned validators > > > > If that is the case, then you would have to put that logic in the > > validator (i.e. in a regular expression validator you would have to > > account for empty values). Perhaps it would be useful to be able to tag > > a field as optional? > > I think so. I don't want the converter to run on an empty field either. I have checked in changes to the CVS which implement an "optional" flag on a FormElement. If the element is optional then validation, conversion and storing will be skipped. Check out the example application to see examples of the optional flag. > > I also think it would be nice to have these ValidationResultMap methods: > > String getOriginalValue(name): Should only return null if name doesn't > exist. > Object getConvertedValue(name): Can return null. > Object getConvertedOrOriginalValue(name): Return the original value if > invalid--otherwise the converted one. > String [] getGroupErrorMessages() > String getErrorOrMessage(name): Return the message if valid--otherwise the > error msg. > > Instead of having to deal with two ValidationResultMaps, it would be nice to > have a wrapper object. Right. I will look into adding these methods. -Anthony |