mail2bansi (2) [Avatar] Offline
My requirement is
" Our users are Authenticated by External System . On successful
authentication the external system returns header variables viz. userId,
firstName, lastName etc to our System.
Currently I am able to retrieve these header variables using
request.getHeader("userId") in my JSP page.
But this is certainly not the best practice. I am thinking of storing this
information in Backing Bean via Phase Listener for further use like
1) retrieving user Roles from the Database based on userId and
2) displaying JSP page based on user roles

I am not sure how to tie up PhaseListener with the Backing Bean . I mean how
do I call backing bean method from Phase Listener if I retrieve header
variables in afterPhase method.

Here are my snippets of code

Faces-config.xml :


public void afterPhase(PhaseEvent pe)
System.out.println("after - " + pe.getPhaseId().toString());

if (pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
System.out.println("Done with Request!
Map requestHeaderMap = new HashMap();

requestHeaderMap =

System.out.println("Hash Map Size:"+requestHeaderMap.size());

String bemsId = (String)requestHeaderMap.get("USERID");


Any pointers/suggestions with little snippets of code will be highly

kito75 (49) [Avatar] Offline
Re: How to call Backing Bean method from Phase Listener

You can easily retrieve a backing bean by accessing the EL programmatically. You can do this through the Application class, which has methods for creating and evaluating EL expressions. So, for example, you could get a reference to geetingForm like so:

GreetingForm form = (GreetingForm)application.getVariableResolver().resolveVariable("greetingForm");

See the book for details.

Kito D. Mann - Author, JavaServer Faces in Action - JavaServer Faces FAQ, news, and info

* Sign up for the JSF Central newsletter! *
sandy312 (1) [Avatar] Offline
Re: How to call Backing Bean method from Phase Listener
Hi I am having a similar problem like this. can you please share some information on this.


SteveColin (1) [Avatar] Offline
Re: How to call Backing Bean method from Phase Listener
I was delighted to find this web site.I wanted to thank you for your time reading this wonderful!
561191 (1) [Avatar] Offline
Such a great post to know different useful information.
Logo Mines
Online Design (1) [Avatar] Offline
561191 wrote:Such a great post to know different useful information.
Online Design Company

Yes, it is this website make true and good branded logo