• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Destination Action URL from FacesContext.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The application I am currently working on has a left navigation menu where the tab corresponding to page currently under display needs to be highlighted.

I am trying to set the outcome of NavigationContext to the action Url, but I am unable to fetch the destination Url from FacesContext.

I have tried the following options:

FacesContext.getCurrentInstance().getViewRoot().getViewId() : This gives me my request page.

FacesContext.getCurrentInstance().getApplication().getViewHandler()

Even tried getting the requestMap from ExternalContext. But could not get the destination url. I am able to navigate to the correct page based on whatever request I make. How can i get the Url/ Id corresponding to the page to be displayed next?
[ June 30, 2008: Message edited by: Ankita Ag ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF newbie techhie, please check your private messages
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Ankita, and thanks for giving us a real name so we can continue the pretense that we're all a credible bunch of professionals here.

It's almost always a sign you're doing something wrong when you start chasing around in the insides of JSF. JSF is intended to put as little JSF-specific code in your JSF app as possible.

In your case, the bigger problem is that the destination URL is meaningless. URLs - despite what a lot of people think - are not pathnames to files - they're literally Uniform Resource Locators, which means that they mean whatever the server needs them to mean in order to locate resources.

To take this one step further, the URL carries almost none of the information needed to keep a JSF page conversation going. A great deal of the necessary context is in the user's session and in POST data. Because of this, JSF doesn't spend much time tracking navigation via the URL and the URL used will often have no obvious relation to your position in the application screen flow.

So, in short, this isn't the way to go. It probably can't be made to work at all, and if it can, is likely to be really ugly and unreliable.

On the other hand, I think I can offer something more workable.

If you set up a backing bean for the menu that contains the menu items and some sort of method for setting and tracking the current page, the backing logic for a page can notify the menu backing bean that that page is displayed and then the JSF snippet that renders the menu can highlight the selected page's commandLink.
 
reply
    Bookmark Topic Watch Topic
  • New Topic