Reputation: 458
I have managed bean, and want to divide logic inside one of its methods according to which page called it, does some way exist to achieve this?
Upvotes: 4
Views: 2115
Reputation: 1108782
This is available by UIViewRoot#getViewId()
.
String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
I must however say that this is somewhat a smell. Depending on the concrete functional requirement for which you thought that examining the calling XHTML page would be the right solution, there may be better ways to achieve the concrete functional requirement.
Upvotes: 9
Reputation: 2738
I think in two approachs the first is to get the referer header from the Http request it may have the url from the requesting page
FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap().get("referer")
Other option is to navigate sending parameters, for example adding the viewId as parameter in the query string, in jsf-2 you can send parameters when the page navigate using the
I hope this will help you
Upvotes: 1