That code doesn't look great indeed. A patch for a refactor would imo
be welcome.

Cheers,

Eelco


On 4/11/07, ChuckDeal <[EMAIL PROTECTED]> wrote:
>
> I was working with wicket.datetime.util.DateConverter in an attempt to try
> and get it to report a parse error instead of silently accepting the bad
> input, when I nrealized that if it threw a ConversionException, the
> framework would be able to pick up on that (in my case
> FormComponent.convert() would catch it) and allow me to register the
> feedback error message.
>
> While following that thread, I noticed that not only was there identical
> code in FormComponent.convert in the two catch blocks, but a third class
> TypeValidator was also using the same block of code:
>
> Map args = new HashMap();
> final Locale locale = e.getLocale();
> if (locale != null)
> {
>     args.put("locale", locale);
> }
> args.put("exception", e);
> Format format = e.getFormat();
> if (format instanceof SimpleDateFormat)
> {
>     args.put("format", ((SimpleDateFormat)format).toLocalizedPattern());
> }
>
> All this block is really doing is analyzing the ConversionException to build
> the args HashMap for the error reporting facilities.  I was thinking that if
> this code block was refactored INTO the ConversionException then the code
> duplication could be removed (as the first benefit), but then Converters
> would be able to inject their own variables into the Map to allow for even
> better message definitions.
>
> While I was looking at the usage of ConversionException, it also looked like
> AbstractConverter, AbstractNumberConverter,
> PropertyResolver$ArrayPropertyGetSet, and PropertyResolver$MethodGetSet
> might all benefit from the refactor by externalizing their messages and
> inject the proper variables into the Exception's Map.
>
> If I haven't missed the mark too bad, I can write a JIRA for this.  Also, I
> could even try the refactor given my description here and any feedback that
> you give me.
>
> Chuck
> --
> View this message in context: 
> http://www.nabble.com/ConversionException-refactor-tf3559528.html#a9940039
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to