Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PhaseListener?

 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic