I think I've found the problem. During field validation, Field.validate() calls DefaultValidator.assertValidity() (Field:450) for the field in question, passing in the candidate value (from the form). Inside DefaultValidator.asserValidity() a test is made for value length (DefaultValidator:213). My value fails this test (it's too short), so the 'message' is set the 'minLengthMessage' (DefaultValidator:215). The a new ValidationException is thrown (DefaultValidator:216). This exception is caught by Field.validate() (Field:457). Unfortunately, this bypasses the (overidden) StringField.doSetValue(pp) call on line 454. As such, setTestValue() never gets called, and Field.testValue never get set, resulting in no value being displayed back in your form.
Now, the question is, what do I do about this? I suppos that I could not use the IntakeService, but I would *really* like to. An obvious alternative would be to fix/patch locally. I'm not sure how much time that would take, I've never compiled Turbine before. Any other suggestions? -Mitch PS It would be nice if someone would be kind enough to validate/invalidate my findings in case I'm totally wrong on this one. -----Original Message----- From: John McNally [mailto:jmcnally@;collab.net] Sent: Tuesday, October 22, 2002 5:29 PM To: Turbine Users List Subject: Re: Using Intake to redisplay invalid form data after validation Can you test some of the other field types? john mcnally On Tue, 2002-10-22 at 08:55, Mitch Christensen wrote: > Hey All, > > Is it necessary to use a "business object" behind the intake service in > order to access the invalid 'value' of a field upon redisplaying a form? > > My scenario is this, I present an empty form. The user inputs some invalid > data. Using intake, I validate the form and redisplay the form with error > message(s). There error message shows up fine, but setting the "text" > input's value="$GroupVariable.[FieldName]" doesn't redisplay the invalid > data originally input by the user (it's empty). I'm not currently using a > "business object" behind the scenes, is this necessary? If not, any ideas > why the original (invalid) data isn't accessible from the intake pull tool? > > Thanks, > Mitch > > FWIW, here is a snippet from my .vm page showing the form and my > intake.xml... > > ---------------------form snippet----------------------------------------- > ... > #set($CaseNumberGroup = $intake.CaseNumberSearch.Default) > <form name="search" method="post" > action="$link.setPage("CaseNumber.vm").setAction("CaseNumberSearch")"> > ... > <!-- first field --> > #if ( $CaseNumberGroup.CaseNumber.isValid() ) > <input type="text" name="$CaseNumberGroup.CaseNumber.Key"> > #else > <input type="text" name="$CaseNumberGroup.CaseNumber.Key"> > <span class="error">$CaseNumberGroup.CaseNumber.Message</span> > #end > ... > <!-- second field --> > #if ( $CaseNumberGroup.FromDate.isValid() ) > <input type="text" name="$CaseNumberGroup.FromDate.Key"> > #else > <!-- *****HERE LIES THE PROBLEM! THE value="" IS ALWAYS EMPTY***** --> > <input type="text" name="$CaseNumberGroup.FromDate.Key" > value="$CaseNumberGroup.FromDate"> > <span class="error">$CaseNumberGroup.FromDate.Message</span> > #end > ... > <!-- obligatory hidden fields --> > $intake.declareGroups() > ... > > > > ----------------intake.xml---------------------------------------------- > <?xml version="1.0" encoding="ISO-8859-1"?> > > <input-data basePackage="us.costars.formbeans."> > > <!-- validation for the CaseNumber search page --> > <group name="CaseNumberSearch" key="caseNumberSearchKey"> > > <!-- validate the case number --> > <field name="CaseNumber" key="CaseNumberKey" type="String"> > <rule name="required" value="true">Case number is required</rule> > <rule name="minLength" value="7">Must be 7-15 characters long</rule> > <rule name="maxLength" value="15">Must be 7-15 characters long</rule> > </field> > > <!-- validate the Form # --> > <field name="FormNumber" key="FormNumberKey" type="String"> > <rule name="maxLength" value="4">Must be exactly 4 digits</rule> > <rule name="mask" value="^$|[0-9][0-9][0-9][0-9]">Requires exactly 4 > digits</rule> > </field> > > <!-- validate the from date --> > <field name="FromDate" key="FromDateKey" type="String"> > <rule name="mask" > value="^$|[0-1][0-9]/?[0-3][0-9]/?[12][90][0-9][0-9]">Invalid date > format</rule> > </field> > > <!-- validate the to date --> > <field name="ToDate" key="ToDateKey" type="String"> > <rule name="mask" > value="^$|[0-1][0-9]/?[0-3][0-9]/?[12][90][0-9][0-9]">Invalid date > format</rule> > </field> > > </group><!-- CaseNumberSearch --> > > > </input-data> > ---- > > -- > To unsubscribe, e-mail: <mailto:turbine-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: <mailto:turbine-user-help@;jakarta.apache.org> -- To unsubscribe, e-mail: <mailto:turbine-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:turbine-user-help@;jakarta.apache.org> -- To unsubscribe, e-mail: <mailto:turbine-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:turbine-user-help@;jakarta.apache.org>
