Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we access session scope variables directly in JSF xhtml files

Hi I am working on a JSF project, I will like to access some session level variables onto my xhtml UI pages directly without using any managed bean.

Just wanted to know if this is possible and if yes than how?

Thanks

like image 316
NKS Avatar asked Oct 18 '13 08:10

NKS


1 Answers

Yes its possible

If the bean doesnot exits then put it in session first

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

And to use the bean on xhtml page use

<h:outputText value="#{sessionScope.key}" /> 
like image 144
BholaVishwakarma Avatar answered Oct 22 '22 20:10

BholaVishwakarma