aspose file tools*
The moose likes JSF and the fly likes PhaseListener? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "PhaseListener?" Watch "PhaseListener?" New topic
Author

PhaseListener?

Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Hi All

Can anyone help me with a PhaseListener?

I have an navigation action which loads a certain jsp page. How can I intercept that navigation rule and, based on a simple test, redirect to a different page.

So I have:

<x:commandLink action="load"/>

I want to do a check when this is clicked to see if a variable is set and if it is then follow the default navigation rule for "load" in faces-config.xml, else I want to direct to a different JSP.

Any advice welcomed

Thanks


ph34r my 133t j4v4 h4><0r1ng sk177z
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Why can't you just do that in your load method? Just return a different string and base your navigation on that. For example:





I think that would be easier.


GenRocket - Experts at Building Test Data
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I believe you can bind the action attribute to a method that performs the functionality you are looking for. The method should return a String that corresponds to the correct navigation outcome.

I think the current use of "load" is not a binding, Gregg, but a definition of an outcome.

To bind it, it should look like:
action="#{handlingClass.load}"
and the handling class (whatever it is) should have a load method that runs a check like the code Gregg showed.
[ July 20, 2005: Message edited by: Marc Peabody ]

A good workman is known by his tools.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Marc Peabody:
I believe you can bind the action attribute to a method that performs the functionality you are looking for. The method should return a String that corresponds to the correct navigation outcome.

I think the current use of "load" is not a binding, Gregg, but a definition of an outcome.

To bind it, it should look like:
action="#{handlingClass.load}"
and the handling class (whatever it is) should have a load method that runs a check like the code Gregg showed.

[ July 20, 2005: Message edited by: Marc Peabody ]


Right. I was asumming his code to be psuedo code. So it should have been what you suggested. Doing so would make my code work. Thanks for pointing that out. I still say its easier than dealing with PhaseListeners.
Rick Beaver
Ranch Hand

Joined: Dec 14, 2004
Posts: 464
Thanks guys

I may have to re-write my navigation system to use method bindings for this to work. I have a whole nav system based on direct value outcomes so I need to rework the code to use method bindings.

I was hoping there was an easier way rather than changing the nav but it seems I will have to.

Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PhaseListener?