Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out which XHTML page called managed bean's method

Tags:

jsf

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?

like image 609
Lostboy Avatar asked Dec 26 '22 16:12

Lostboy


1 Answers

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.

like image 94
BalusC Avatar answered Jan 28 '23 04:01

BalusC