I am creating web page using JSF 2.0.
What I want to do is, call one method setLastVisitedPage that I have in bean MyBean when everypage loads.
I can do this by simply writing
<h:body onLoad="#{MyBean.setLastVisitedPage()}"
however I would have to write in all pages and already there are 30-40 pages created. :(
In page as I have common heading, I have created one file called commonPage.xhtml. I was thinking to include that file here.
So I added below in commonPage.xhtml so that whenever any page is loaded, myScript.js gets called and I get alert as "i m here".
<h:outputScript name="js/myScript.js" target="head" />
and myScript.js has
onload = alert("i m here");
Whenever I open any new page, I am getting alert as "i m here".
Now my question is how can I add #{MyBean.setLastVisitedPage()} in javascript so that setLastVisitedPage() get called for every page?
Is there any alternative way? May be I am thinking in wrong way.