views:

21

answers:

1

I want to access the JSFUnit FacesContext before I create the JSFSession object. The reason for this is I would like to set a managed bean value before any request/response processing is done. I use this value in a filter.

+1  A: 

I am not sure exactly what do you want to accomplish, however, if you want to set values before any request will be processed, use WebClientSpec with setInitialRequestStrategy.

For example, you can use FormAuthenticationStrategy:

WebClientSpec wcSpec = new WebClientSpec("/secure.jsp");
      FormAuthenticationStrategy formStrategy = new FormAuthenticationStrategy("user", "password");
      formStrategy.setSubmitComponent("login_button");
      wcSpec.setInitialRequestStrategy(formStrategy); 
      JSFSession jsfSession = new JSFSession(wcSpec);

or define your own custom request strategy that implements InitialRequestStrategy.

See FormAuthenticationStrategy code and create something similar to it.

Odelya
Would this also work for managed beans?
Panayiotis Karabassis