Hi Richard, > > The DateTypeConverter already supports several date formats, and it > > is easy to customize them to your own. The type converter is able to > > accept the user input in any of those formats. > Yes, but it is too lenient with dates. If the user makes a typing > error the date created is a total mess. Here's an example: > [...]
The DateTypeConverter accepts several formats by default, but if you find it too lenient, you can just override the formats to only those that you wish to accept. Personally I like to use yyyy-MM-dd only. > Let me argue with another example: > <s:text name="stock.risk" formatType="percentage"> > This renders to an html input tag with a % at the end of the number. > Submitting this form without changing the value ends up in a > ValidationError. The PercentageTypeConverter is the type converter that corresponds to the percentage format. > This is not what I would expect if I don't know the > frameworks details and what I mean by inconsistent - from a framework > user point of view. I agree with you that this is perhaps not as POLS as it could be (Principle Of Least Surprise). > For my CalendarTypeConverter this means, that I will show my user a > time and let him enter a date and time or only a date if do not make > use of the Validation annotations. If I use Validation annotations I > repeat my self and some voice in my had tells me that this is not a > good thing Indeed, it would be nice to keep the format pattern and type conversion tightly together. You are able to format a Date as "time only", but your CalendarTypeConverter does not know that the input should be "time only" in this case. If it did, you'd probably have some code somewhere that says "if formatType == time only ...". You could extract that part of the code into a TimeTypeConverter and tell Stripes to use it on the field for which the formatType is time. Of course, this solution is not as nice as what you are proposing, because you have the additional task of adding @Validate(converter=TimeTypeConverter) on those fields, and you need separate type converters instead of an "all in one". > Did you catch my thoughts(I'm not very good in converting things from > my mind to written words in a foreign language )? If so, are the > reasonable or did I miss something? You express yourself very well and your thoughts are quite reasonable. Maybe it's something to consider for a future version of Stripes. Anyone else have thoughts on this? Cheers, Freddy http://www.stripesbook.com ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
