[ http://mc4j.org/jira/browse/STS-445?page=all ]

Tim Fennell resolved STS-445.
-----------------------------

    Fix Version/s: Release 1.5
       Resolution: Fixed

I've just checked in Freddy's version (attached to STS-445)  with some edits.  
I believe it solves /most/ problems.  Firstly a couple of points for everyone 
to remember:

1. In the trunk/1.5 code base TypeConverterFactory.add() is now public - you 
don't need to write your own factory to add custom converters, you just need to 
register them at startup (in an existing context listener or base action bean 
perhaps?)

2. You can choose to extend Stripes' DateTypeConverter, but if you don't like 
it or you're finding it hard work, you are also free to write your own from 
scratch (even taking the code from DateTypeConverter - it's ASL licensed).  If 
all you want is to parse one very specific format it's probably easier to write 
a new class and it'd be about 4-5 lines of actual code!!!!

With that out of the way, here are the changes between the 1.4 version and what 
I just checked in:

a. Documentation is clearer about the fact that patterns (by default) should be 
white space separated

b. There is now a single getFormatStrings() method that returns format strings 
INCLUDING the default Locale ones. This means that overriding this method alone 
will now replace ALL format strings, not just a subset of them.

c. getFormatStrings() will look in the resource bundle for format strings, and 
if found they will supercede all format strings (including the Locale default 
ones)

d. The pattern for preprocessing (which matches "what should be replaced with 
single spaces") is now overridable in code and in the resource bundle

e. Pre-processing is broken into two methods to that it's easy to disable all 
or part of it with a no-op override.  The methods are preProcessInput() which 
does the regex replacement and then delegates to checkAndAppendYear() which 
checks to see if it is a two-part Date (i.e. day and month) and appends the 
year to the String to enable parsing

> Define custom date formats in StripesResources
> ----------------------------------------------
>
>                 Key: STS-445
>                 URL: http://mc4j.org/jira/browse/STS-445
>             Project: Stripes
>          Issue Type: Improvement
>          Components: Validation
>    Affects Versions: Release 1.5
>         Environment: Mac OS X 10.4.11, JDK1.5.0_07
>            Reporter: Iwao AVE!
>         Assigned To: Tim Fennell
>             Fix For: Release 1.5
>
>         Attachments: DateTypeConverter.java, DateTypeConverter.java, 
> DateTypeConverter.java
>
>
> John Newman had explained the problem accurately.
> I copied his comment from another issue.
> http://mc4j.org/jira/browse/STS-443#action_10935
> --
> it is currently too hard to add an extra format string
> 1) subclass DateTypeConverter
> 2) add in format string (mess due to array)
> 3) subclass TypeConverterFactory to use new DateConverter
> 4) register that in web.xml
> I have to do that in almost every app as every user has different ideas about 
> the way dates should be entered. it would be nice if I could just throw a 
> couple lines in that resource file and be done with it!
> --

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-development mailing list
Stripes-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to