Can we access session scope variables directly in JSF xhtml files

Hi, I am working on a JSF project, I would like to access some session level options on my xhtml user interface pages directly without using managed beans.

I just wanted to know if this is possible, and if so, how?

thanks

+6
source share
1 answer

Yes its possible

If the bean does not exit, first put it in a session

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key,object); 

And to use the bean page on xhtml use

 <h:outputText value="#{sessionScope.key}" /> 
+6
source

Source: https://habr.com/ru/post/956224/


All Articles