I may have already checked in a fix for the copyright. On Tue, Feb 17, 2009 at 8:14 AM, Kevin Menard <[email protected]> wrote: > Heh. I really don't know what other validations can be done. One > thing I'm sure of is that someone will come up with something. > > Apologies on the copyright stuff. I always forget about this the > first couple months into a new year. If it's any consolation, I still > sign stuff 2008. I'll commit a fix for that later when I'm back at a > workstation. > > -- > Kevin > > > > On Tue, Feb 17, 2009 at 10:39 AM, Howard Lewis Ship <[email protected]> wrote: >> Great ... this is something people have been asking for a while >> (though beyond "required", how much validation can you do?). >> >> Please keep an eye to copyright years when committing. >> >> On Tue, Feb 17, 2009 at 4:25 AM, <[email protected]> wrote: >>> Author: kmenard >>> Date: Tue Feb 17 12:25:16 2009 >>> New Revision: 744998 >>> >>> URL: http://svn.apache.org/viewvc?rev=744998&view=rev >>> Log: >>> Fixed TAP5-166: Add validator support to RadioGroup >>> >>> Modified: >>> >>> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java >>> tapestry/tapestry5/trunk/tapestry-core/src/test/app1/RadioDemo.tml >>> >>> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java >>> >>> Modified: >>> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java >>> URL: >>> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java?rev=744998&r1=744997&r2=744998&view=diff >>> ============================================================================== >>> --- >>> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java >>> (original) >>> +++ >>> tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java >>> Tue Feb 17 12:25:16 2009 >>> @@ -62,6 +62,14 @@ >>> @Parameter(required = true, allowNull = false) >>> private ValueEncoder encoder; >>> >>> + /** >>> + * The object that will perform input validation. The validate binding >>> prefix is >>> + * generally used to provide this object in a declarative fashion. >>> + */ >>> + @Parameter(defaultPrefix = BindingConstants.VALIDATE) >>> + @SuppressWarnings("unchecked") >>> + private FieldValidator<Object> validate; >>> + >>> @Inject >>> private ComponentDefaultProvider defaultProvider; >>> >>> @@ -80,6 +88,9 @@ >>> @Environmental >>> private ValidationTracker tracker; >>> >>> + @Inject >>> + private FieldValidationSupport fieldValidationSupport; >>> + >>> private String controlName; >>> >>> String defaultLabel() >>> @@ -138,11 +149,20 @@ >>> >>> private void processSubmission() >>> { >>> - String clientValue = request.getParameter(controlName); >>> + String rawValue = request.getParameter(controlName); >>> >>> - tracker.recordInput(this, clientValue); >>> + tracker.recordInput(this, rawValue); >>> + try >>> + { >>> + if (validate != null) >>> + fieldValidationSupport.validate(rawValue, resources, >>> validate); >>> + } >>> + catch (ValidationException ex) >>> + { >>> + tracker.recordError(this, ex.getMessage()); >>> + } >>> >>> - value = encoder.toValue(clientValue); >>> + value = encoder.toValue(rawValue); >>> } >>> >>> /** >>> @@ -222,11 +242,8 @@ >>> return null; >>> } >>> >>> - /** >>> - * Returns false; RadioGroup does not support declarative validation. >>> - */ >>> public boolean isRequired() >>> { >>> - return false; >>> + return validate.isRequired(); >>> } >>> } >>> >>> Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/RadioDemo.tml >>> URL: >>> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/RadioDemo.tml?rev=744998&r1=744997&r2=744998&view=diff >>> ============================================================================== >>> --- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/RadioDemo.tml >>> (original) >>> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/RadioDemo.tml Tue >>> Feb 17 12:25:16 2009 >>> @@ -6,7 +6,9 @@ >>> <p>Choose a department and position:</p> >>> >>> <t:form> >>> - <t:radiogroup t:id="department"> >>> + <t:errors/> >>> + >>> + <t:radiogroup t:id="department" t:validate="required"> >>> <t:loop source="departments" value="loopValue"> >>> <p> >>> <t:radio t:id="radio" value="loopValue" label="prop:label" /> >>> >>> Modified: >>> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java >>> URL: >>> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=744998&r1=744997&r2=744998&view=diff >>> ============================================================================== >>> --- >>> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java >>> (original) >>> +++ >>> tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java >>> Tue Feb 17 12:25:16 2009 >>> @@ -1107,6 +1107,18 @@ >>> } >>> >>> @Test >>> + public void radio_group_validator() >>> + { >>> + start("RadioDemo"); >>> + >>> + String update = SUBMIT; >>> + >>> + // Verify that the "required" validator works. >>> + clickAndWait(update); >>> + assertTextPresent("You must provide a value for Department."); >>> + } >>> + >>> + @Test >>> public void regexp_validator() >>> { >>> start("Regexp Demo"); >>> >>> >>> >> >> >> >> -- >> Howard M. Lewis Ship >> >> Creator Apache Tapestry and Apache HiveMind >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
-- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
