Accessing DWR message data in Spring interceptor
I have a DWR action with a method signature like this:
String joinGroup(String groupId, String groupName);
This is triggered via a DWR AJAX request and works fine.
However I am trying to write a Spring interceptor (works the same as ServletFilter) to do some authentication work before calling the DWR action.
The interceptor is being called correctly, but I need to access the groupId and groupName data in the interceptor.
The request parameter map is empty and I have gone through the whole list of request attributes in the debugger and I cannot see the data anywhere.
The postData request is also null.
Using firebug I can see the data being pushed to the server (and that's there when the joinGroup method is eventually called).
I just cannot access it in my interceptor.
Is there a way to access it at all?
a source to share
Using org.directwebremoting.AjaxFilter
The doFilter AjaxFilter method is called by DWR every time an Ajax request is made according to the method with which this filter is configured. The AjaxFilterChain passed to this method allows the filter to pass method details to the next object in the chain.
Typically, the method does the following:
- Explore the request
- You don't have to change the method, object or parameters
- Either call the next object in the chain using AjaxFilterChain, or choose to take other actions instead.
- Modify the value returned to the user as needed
- Take a few other actions (like logging)
a source to share
I am assuming that you are using a MethodInterceptor that is called (meaning your config is correct) only on the above method.
...
@Override
public Object invoke(MethodInvocation inv) throws Thorwable {
Object[] args = inv.getArguments();
String groupId = args[0];
String groupName = args[1];
.... if user has access call inv.proceed, else throw AccessDeniedException
}
The Spring Framework Interceptor is pretty much identical to the Spring Security MethodSecurityInterceptor .
a source to share