1

I need something that will uniquely identify my JSF (XHTML) page.

I know that I have:

String URI = servletRequest.getRequestURI();

This gives my full path, but that doesn't help if I use PrettyFaces or any other URL changing library.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Nikola
  • 624
  • 1
  • 14
  • 31

1 Answers1

2

You can use UIViewRoot#getViewId() for this:

String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();

It's also available in EL as follows:

#{view.viewId}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555