我想在创建JSFSession对象之前访问JSFUnit FacesContext。这样做的原因是,我希望在完成任何请求/响应处理之前设置一个托管bean的值。我在过滤器中使用这个值。
发布于 2010-08-23 18:36:33
我不确定您到底想要实现什么,但是,如果您想在处理任何请求之前设置值,请结合使用WebClientSpec和setInitialRequestStrategy。
例如,您可以使用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);或者定义实现InitialRequestStrategy的自定义请求策略。
查看FormAuthenticationStrategy代码并创建类似的代码。
https://stackoverflow.com/questions/3542737
复制相似问题