Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top