Fred, I think that I am seeing eye-to-eye with you on your vision. This is good stuff and I hope it doesn’t get lost in the near future. If you can, can you open a jira issue with these various aspects and/or continue to keep tabs on progress towards this goal?
-Pat
-----Original Message-----
Jason, I've many remarks about the XWork conversion mechanism.
1/ It would be cleaner to use setDefaultConverter(new XWorkBasicConverter()) than fulfilling the xwork-default-conversion.properties with the current entries that refers to the XWorkBasicConverter. 2/ I'm wondering if catching every exception when converting a value is clean, because you don't make the difference between runtime exceptions and the controlled TypeConversionException. I would be inclined to handle only TypeConversionException exceptions. 3/ I think that returning the value acceptableErrorValue(toClass) when a converter fails is strange enough. Don't you think it sould be the converter that must return the default value ? -> return tc.getDefaultValue(toClass), surely a new method to add to the TypeConverter interface. 4/ I personnaly dont like the idea of a special interceptor to handle specific values and preventing type conversion exceptions. On the other hand, the idea of dealing with the conversion errors with the validation framework is welcomed. I explain my point of view :
class DateConverter
public Object defaultValue = null;
public object getDefaultValue() { return defaultValue; }
public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) { if(value==null) return defaultValue;
if( ... ) ...
else if (Date.class.isAssignableFrom(toType)) SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
try } In XWorkConverter
try {
return tc.getDefaultValue(); -> I handle only TypeConversionException exceptions -> The conversion error is stored in the context to be retrieved (if wanted) by the validation framework -> I return tc.getDefaultValue()
In my validation conf file
<field name="myDate">
<field-validator type="required"> ] With this vision, you dont have to use a special interceptor, only if converters do correctly their job. Hope it can help.
Richard
HALLIER
[Richard Hallier]
-----Message
d'origine-----
|
Title: Message
- [OS-webwork] Type Conversion Handling Jason Carreira
- RE: [OS-webwork] Type Conversion Handling Fred Lamuette
- RE: [OS-webwork] Type Conversion Handling Patrick Lightbody
- RE: [OS-webwork] Type Conversion Handling Fred Lamuette