I want to install my own NavigationHandler into the javax.faces.application.Application object. I know that I can do this using a PhaseListener, but I think this operation is something that could be done just once. I was wondering what the best practice was for the placement of code to alter JSF that could be run at start-up, so to speak? Does the JSF provide any special hooks for this?
I have found a way that almost works for me, and might work for others. You can specify what class you want instantiated used as your navigation handler in your faces-config file:
Ideally, I'd like my navigation handler to take whatever is the default navigation handler and decorate it, but with this approach, I'm forced to hardwire in class org.apache.myfaces.application.NavigationHandlerImpl, for example.
Joined: Sep 16, 2005
Oh happy day! I found a solution and it's simple. Let me summarize my problem: I wanted to write a custom NavigationHandler backed by whatever is the default navigation handler:
I wanted to install this component at JSF startup, so I added to my faces-config:
The problem was how to set the base navigation handler -- it only needs to be done once, but the only place I could think of doing it was from a PhaseListener. Then I came across an example of a custom navigation handler that didn't define a default constructor -- my mistake was that I had thought that was necessary. So I changed my code to:
And this new constructor is being successfully called because of the same config file reference I listed a few lines ago. [ March 07, 2006: Message edited by: Jeff Albertson ]