1

I have this situation, where I have to access the entire faces config from a managed beans. More specifically, I need to access the list of navigation cases, that were specified in the faces-config and cycle through them. Is there any way to get them?

I saw that NavigationCase has some good methods that reveal some useful information .. Question is now, how to get a list of these NavigationCase

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Arijit Datta
  • 101
  • 1
  • 2
  • 10

2 Answers2

1

Based on the Tags you have specified in your question, i can say that you are using JSF 2, so you can use the ConfigurableNavigationHandler to get what you are looking for.

Use the ConfigurableNavigationHandler#getNavigationCases() to get a Map of Navigation cases, you can get more informations about that method from it's Javadocs:

Return a Map<String, Set<NavigationCase>> where the keys are values and the values are Set where each element in the Set is a NavigationCase that applies to that .

This is an example for invoking that method:

FacesContext context = FacesContext.getCurrentInstance();
ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
Map<String,Set<NavigationCase>> navigationCases = navigationHandler.getNavigationCases();

In case you already knew the name of the page you want to navigate to, you can simply use that example (assuming your page file is next.xhtml):

FacesContext context = FacesContext.getCurrentInstance();
ConfigurableNavigationHandler navigationHandler= (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
navigationHandler.performNavigation("next");

See also:

Community
  • 1
  • 1
Tarik
  • 4,961
  • 3
  • 36
  • 67
0

try this code:

FacesContext ctxt = FacesContext.getCurrentInstance();
ConfigurableNavigationHandler configNavHandler = (ConfigurableNavigationHandler)ctxt.getApplication().getNavigationHandler();
NavigationCase navCase = configNavHandler.getNavigationCase(ctxt,null,"Page");
String toViewId = navCase.getToViewId(ctxt);
Mauro Midolo
  • 1,841
  • 3
  • 14
  • 34