I have done some research how to implement a JSF Action-Method-Interceptor.
In the JSF specification you can provide a JSF action listener implementation in the faces-config.cfg:
This instance is create on application startup an can be accessed over the FacesContext:
event.getFacesContext().getApplication().getActionListener();
I thought this action listener must be invoked for every action request and before the action method in the backing bean was invoked.
The code in my ActionListener class is never invoked and I don't know if there is any configuration problem or maybe I'm wrong with the action-listener behavior of JSF or CaptainCASA.
Really, what I want is to intercept every backing bean method invocation in order to check some issues about security and so on.
If you know another way to do it please let me know. I have also tested to intercept the action method with the BEANMETHODINVOKER -Component. This doesn’t work because I want to retrieve in the action-listener method the called component of the ManagedBean and not the BEANMETHODINVOKER-Component:
i tested the action interceptor. works good for my purposes. good improvement of the framework! but i still have some questions:
i implemented the interceptor interface in our own dispatcher:
public class Dispatcher extends WorkpageDispatcher implements IMethodBindingListener {
...
public Dispatcher() {
...
HttpSessionAccess.setMethodBindingListener(this);
}
reactOnListenerInvokeAfter() {
...
}
reactOnListenerInvokeBefore() {
...
}
1. Every user has his own „dispatcher“ because the ManagedBean is registered in the "session" scope of JSF. The „dispatcher“ calls HttpSessionAccess.setMethodBindingListener(this) on instantiation (see ctor). Is the „dispatcher“ the right place to register the MethodBindingListener? Has every user his own MethodBindingListener in the http session scope?