Re: Date validation tweaks

2006-02-23 Thread Bryan Lewis
While we're on this subject... Tapestry's built-in DateTranslator uses a lenient DateFormat, one of my pet peeves. When a user enters a date like 03/44/2005 it's probably an error... I don't want it silently converted to 04/13/2005. I could override the DateTranslator's behavior in code, add a f

Re: Date validation tweaks

2006-02-23 Thread Bryan Lewis
Thanks guys. Now I can get rid of my custom MaxDate validator class! Martin Carel wrote: > Hi Kirby, > > > > > I just want to mention that I needed to add 'literal' in order for > this to work (otherwise I have a parsing exception as 'ognl' is the > default prefix for page spec): > > > > Than

Re: Date validation tweaks

2006-02-23 Thread Martin Carel
Hi Kirby, > I just want to mention that I needed to add 'literal' in order for this to work (otherwise I have a parsing exception as 'ognl' is the default prefix for page spec): Thanks for this, I can now get rid of my custom MinDate validator class! > To answer your localisation ques

Re: Date validation tweaks

2006-02-23 Thread Martin Carel
Hi! Here is how I solved my tweak #1 (specifying a date (at the beginning of the day) as a default value). I implemented my own TypeConverter: public class IntToDateConverter implements TypeConverter { static private Calendar getTodaysDate(){ Calendar now = Calen

Re: Date validation tweaks

2006-02-23 Thread Richard Kirby
Hi Martin, Sorry, looks like I wasn't looking closely enough at what you wanted to do. I believe your problem is this: class="org.apache.tapestry.form.validator.MinDate,message={0} must be on or before {1,minDate,MMM/dd/}"> Try instead: Note that the 1,date,MM/dd/

Re: Date validation tweaks

2006-02-23 Thread Martin Carel
Hi! Thanks both for your feedback. I successfully solved my tweak 1 (will post another message for explaining how today). > You should also be able to specify a custom format: > {0} must be on or before {1,date,MM/dd/} That'd be nice if I could do that. I used: class="org.apache.tapestr

Re: Date validation tweaks

2006-02-22 Thread Richard Kirby
Hi Bryan, Try Assuming the message conforms to the standard java.text.MessageFormat class, then it should display the date in the standard short format. You should also be able to specify a custom format: {0} must be on or before {1,date,MM/dd/} Cheers Richard Bryan Le

Re: Date validation tweaks

2006-02-22 Thread Bryan Lewis
It's certainly possible to do those things with code, although that approach seems to be falling out of fashion these days. :-) #1. Write a utility method to call instead of java.util.Date(). What I use: public static Date today() { return org.apache.commons.lang.time.DateUtils.trun