From: Anthony E. <me...@an...> - 2003-05-02 12:00:03
|
Thanks for the patch Dan. I actually changed the line to: if(formData == null || formData.getValue() == null || "".equals(formData.getValue())){ Just in case a null formData object is passed. Sincerely, Anthony Eden Dan Prince wrote: >First. Thanks for all for the nice work done so far. > >I have a small suggestion/fix for a problem I'm having with >default values using HttpForm objects (using the <default> XML tag). >I'm using the HttpForm.process(HttpServletRequest request) method >to validate servlet form data. > >I'm having problems getting formproc converters to use the default >value for form elements. Specifically, when I have an element >set up like this using XMLFormConfiguration: > > <element name="my_variable"> > <default>my_default_value</default> > <converter classname="my.converter.ClassName"/> > </element> > >If the HTTP POST request doesn't contain the parameter "my_variable" >I would like the default value to be sent thru the converter. >But it doesn't work for me. > >I found some code in the Form.java class that looks like may be the >cause of my problem. > >On line 366, a comment reads: > // HTTP form fields with empty values will not be sent with the > // request, thus the formData is null. > >The problem is FormData objects can never be null using the process >methods within the HttpForm form class, because a call is ultimately made to >the the FormUtilities.findFormData() to obtain the form data. >The FormUtilities.findFormData will never return null. > >So on line 372 where the code tests to see if the default value should >be used for the formData, it will always fail when using the HttpForm class. > >As a fix I changed line 372 in Form.java to the following: > > if(formData.getValue() == null || "".equals(formData.getValue())){ > >Any thoughts on this? > > > |