-
1. Re: Is @Inject available in Servlet Filter?
jharting Jun 20, 2013 8:30 AM (in response to wangliyu)1 of 1 people found this helpfulYes you can in an EE-compliant server and the Weld-servlet module also supports that on Jetty and Tomcat.
-
2. Re: Is @Inject available in Servlet Filter?
wangliyu Jun 25, 2013 8:14 AM (in response to jharting)I did some test, the @Inject did work with WELD 2.0 on Tomcat (WELD2.0.0.SP1, Tomcat7), but it seems not working with JSF phase listener (JSF2.1.22), is this true or I need do some other stuff to make it work?
-
3. Re: Is @Inject available in Servlet Filter?
mkouba Jun 25, 2013 8:19 AM (in response to wangliyu)Hi Wang,
how do you mean "not working with JSF phase listener"? Servlet filters are JSF-unrelated...? If you want to inject components into JSF phase listener, I believe you'd have to use JSF 2.2 implementation.
-
4. Re: Is @Inject available in Servlet Filter?
wangliyu Jun 25, 2013 8:36 AM (in response to mkouba)In Servlet I tested:
public class SomeFilter implement Filter {
@Inject
private Event<HttpServletRequest> evt;
...
public void doFilter(ServletRequest req,...) {
...
evt.fire(req);
}
in the PhaseListener, if I did
@Inject
private Event<FaceContext> contextEvent;
public void beforePhase(..) {
...
contextEvent.fire(event.getFaseContext());
..
}
The contextEvent is null at the point it gets called.
I guess I have to upgrade to JSF2.2 to make it work.
Samething in the JSF ErrorHandler.
-
5. Re: Is @Inject available in Servlet Filter?
mkouba Jun 25, 2013 8:40 AM (in response to wangliyu)1 of 1 people found this helpfulYes, definitely. Also have a look at http://jdevelopment.nl/jsf-22/#763 and https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-763.