How is using a Filter compared with using a PhaseListener?
Implementing a PhaseListener requires implementing 3 methods:
- public void beforePhase (PhaseEvent event)
- public void beforePhase (PhaseEvent event)
- public PhaseId getPhaseId () //the choice of Faces phase to handle
The 1st 2 methods allow a use of the PhaseEvent parameter, which is very useful to get a FacesContext (FacesContext context = event.getFacesContext();).
Could you please comment on the differences between using a Filter and using a PhaseListener?
Posted by Ophir Radnitz at August 16, 2004 03:07 AMThanks for comments Ophir. Check out my response, a new post on filters and PhaseListeners. You can click on "posted by" to get there.
Posted by Alphageek at August 19, 2004 12:33 AMOn URL http://www.thoughtsabout.net/blog/archives/000033.html
Reference was made to the "servletContext" in Statement:
facesContext = contextFactory.getFacesContext(servletContext, request, response, lifecycle);
but it was never instaniated in the method???
I'm trying to obtain the "ActionEvent" from the Request via a Filter.. I believe this is possible based on your comments???? How could this be accomplished
Posted by Dan Harth at September 24, 2004 10:47 PMThanks Dan for your comments. Yeah, sorry about not mentioning anything about that. "servletContext" actually happened to be a private member that I set in the filter's init(FilterConfig filterConfig) method, by calling filterConfig.getServletContext(), that's why it wasn't instantiated anywhere in the method. I fixed the code in the blog post. Unlike FacesContext, which is set up per every request, servletContext is set up once during the application start-up. If you are using a container confirming to servlet 2.3 spec, you can get a reference to servlet context from HttpServletRequest.getSession().getServletContext() as well.
And to answer your question, yes, getting an ActionEvent in a filter should be possible once you get the facesContext set up.
Posted by Alphageek at September 27, 2004 07:09 PMthank you
thank you
thank you
as a matter of fact, i am using a filter to do authorization, and i ran into the problem you outlined above. your solution worked like a champ.
Posted by tomas at January 4, 2005 12:48 PMNice site, good job.
Posted by Sylvester at October 28, 2005 03:31 PMHi.
Can you tell me how I can get the backing beans from my servlet?
Thanks
Posted by Rune at January 12, 2006 05:10 AMSo I have started in on my project. If this works, this will be a very cool and elegant solution. It involves a ton of experimentation, but hopefully the end result will pay off bigtime. I’m using Chaperon to parse the data. The cool part is that Chaperon includes Cocoon Generators and Transformers, so, hopefully, if I can wrap my head around the workings of Chaperon, I will be able to do all this parsing and decoding from within Cocoon.
Posted by eminem curtain call at January 28, 2006 06:19 PMSaved my day !
Ive created an http based OCSP responder with JSF for the gui part.
The oscp servlet now can access jsf managed beans thanks to your example.
Posted by Rickard at April 4, 2006 09:14 AMIt is said in JSF spec that for non-faces generated request a new life cycle of jsf should be created.can u elaborate on this.I am new to jsf.My requirement is an external web application should send parameters to portal jsf but in my jsf i get null parameter values.Can u pls help me out in this regard
Posted by Lakshmi at May 24, 2006 11:45 PMHow to use the variable resolver? I like to have a class for storing and retrieving some data at application level, not at page level.
Posted by Huib Valstar at September 23, 2006 01:37 AMWonderful articles. Thanks for such a nice information http://anne.messageboard.nl/25247
Posted by Levitra at April 5, 2007 01:46 AMI found lots of intresting things here. Please more updates.
Posted by Albert Bibingo at May 4, 2007 03:49 PM