struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <>
Subject Enum, TypeConversion and error handling
Date Thu, 03 Jan 2008 23:58:35 GMT
Fresh from plugging in my first TypeConverter, I find that on the whole the 
TypeConversion mechanism in S2 is very good. After setting up a custom type 
converter, I thought I could chip in with a couple of comments:

(1) where to register type converter - took a while to discover whether I was 
registering it as intended. The author of the documentation made several 
assumptions about the reader's knowledge of the mechanism that cause a bit of a 
hindrance to understanding what was meant. Unfortunately even though I have edit 
rights to the wiki, I can't change it because it's mostly extracted direct from 
the source code javadocs.

(1b) is it true that the type converter registration process doesn't check 
superclasses - java.lang.Enum for example? I wrote a generic enum converter but 
must register it against each individual enum class. I can see that I would like 
to register most enums with DefaultEnumTypeConverter (converts the text name of 
the enum element) but then I'd register some enums individually with an 
EnumOrdinalTypeConverter (converts an int into the ordinal).

(2) S2 swallows exceptions in XworkConverter. This caused a lot of wasted time. 
I couldn't figure out whether the type converter registration had even worked. I 
needed to step through code to find problem. The original exception admittedly 
was due to bad coding in my TypeConverter subclass, but the resulting exception 
was caught and discarded.

(2b) it was difficult to tell exactly what I should do in my TypeConverter to 
show the message that I really wanted when conversion failed.

(3) I could certainly tweak the documentation but it's difficult with big quotes 
from javadoc - see my previous email to the dev list on this:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message