Type-specific application-scoped error messages for standard conversion

Hello all.

Can I declare application-scoped error messages for standard conversion that are specific to the type being converted? Something like: “For all int conversion erros in the whole application use message ‘foo’; for all date conversion errors in the whole application use message ‘bar’; and so forth…”

Actually, it would be ideal if I could reuse the same error messages in validation configuration, but conversion happens before validation and I can’t use validation mechanism because errors would be detected at conversion time.

If, for instance, an int conversion fails, I wouldn’t like to return a generic “Invalid field” message, but something more informative like “A number was expected” or the like.

Using “invalid.fieldvalue.” in a resource bundle involves using always the same name for the field with a specific type, or repeat the message in every action.

Overriding “xwork.default.invalid.fieldvalue” only permits a generic message for all types.

I guess the only option remaining is creating custom converters that override the default framework converters for standard types: int, Date…

By the way, is is possible such an override of default converters for standard types?

Thanks for your time. Antonio.

Leave a comment

0 Comments.

Leave a Reply