Hi Christian,
MessageBodyReader comes into play when processing the body of the
request. If you are mainly interested in mapping query parameters,
StringReaders/StringReaderProviders are used for that.
There is no straightforward way how the target method could get
informed about a conversion error - it would either not get called at
all (an exception would be thrown from the StringReader, if the value
can't be parsed) or would be called passing the default value to the
parameters (if parameters are not present).
I guess you could get close to what you need by having custom types
for the data you need to extract, and custom StringReaders for those
types - you could have an error field in the custom types which you
can set in your StringReader if the conversion fails.
Martin
On Jan 27, 2011, at 6:35 PM, Christian Helmbold wrote:
> Spring MVC and Grails[1] offer a nice way to convert incoming
> request data into
> domain objects. Conversion errors, like "xy" -> Integer, are reported.
>
>
> I want to do something similar with JAX-RS, but don't know how I
> could do it
> elegantly. A MessageBodyReader came to my mind, but how to report
> conversion
> errors to the method in the resource class, which receives the
> conversion
> result?
>
> Christian
>
>
> [1]
> http://grails.org/doc/latest/guide/6.%20The%20Web%20Layer.html#6.1.6%20Data%20Binding
>
>