Tuesday, 7 May 2013

How to get current page URL from backing bean? | JSF Interview Questions

You can get a reference to the HTTP reuest object via FacesContext like this:
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletReuest reuest = (HttpServletReuest) fc.getExternalContext().getReuest();
and then use the normal reuest methods to obtain path information. Alternatively,
context.getViewRoot().getViewId();
will return you the name of the current JSP (JSF view IDs are basically just JSP path names).


No comments: