Hello everybody,
I need your good advices about the way to get call
parameters within a converter …
In the project I work on, we use DWR with the Spring creator.
Our Spring layer is generated from the great AndroMDA. It has « Service »
classes, with operations having primitive types or java beans as input and / or
return parameters. DWR is a perfect tool to do this, it works great.
Now we need to implement a specific converter for exceptions
thrown by our Spring layer, since the default converter doen’t suit with
our needs. In fact what we need is to translate the exception message before
sending it to JS.
We thought about the following solution :
-
Let say we have a MyService class,
with a myOperation method. This method throws a java.lang.IllegalArgumentException
width « name.required » as a message. In fact it is an
error code rather than an error message.
-
When such an exception is thrown,
the converter has to build a resource key from the error code, using the
service name (script name in DWR) and the method name. For example, the resource
key is « error.myService.myMethod.name.required ». If it
doesn’t exist, we search « error.myService.name.required ».
And if it still doesn’t exist, we search « error.common.name.required ».
So you can see we need to get the name of the service
(script name in DWR) and the name of the method, within the converter code. And
that’s what I can’t do … I tried using the WebContext class
to get the HTTP request, but the request input stream is empty ! Does
anyone has a solution to get the parameters of the call from which the
exception was thrown ?
Note we work width DWR 1.1.3
Thanks in advance
Olivier Thierry