Hi all,
These days I am so muh busy with SOA, ADF and Bpel projects that I do not get time to write articles. But recently helped a friend in old team for fixing browser back button in one of his OAF transaction pages which was creating error in his page.
Basically a small trick used in various J2EE projects in javascript helps to sort of nullify the browser back button in oaf page. This is what you need to do,
Put following code in process request of OAF page :
OABodyBean bodyBean = (OABodyBean) OAPageContext.getRootWebBean();
String javaS = “javascript:window.history.forward(1);”;
bodyBean.setOnLoad(javaS);
Actually window.history.forward(1) would push the current page ahead in the "visited pages history". A negative number like -1 would restore the previous visited page from browser's cache. Zero is relative to the current (displayed) page. Positive numbers would navigate forward.
If the page number (positive) does not exist in history, your browser will create an entry "copying" the current page to it and setting it as the current entry, so that the previous and actual are the same.
Using window.history.forward(1) does not disable "Back button". The button will work BUT as this script runs on page loading, it will send you "ahead" the history, which stored URL (or page) is the same. So it works like a "Refresh" button, without actually refreshing content from server, but just restoring from cache.
Hope this helps all.
5 comments:
window.history.forward(1) is bad syntax as forward() method has no param.
Your tip works only in MSIE.
This works in all browsers :
[html][head]
[script type="text/javascript"]
window.history.forward();
function noBack(){window.history.forward();}
[/script]
[/head]
[body onload="noBack();" onpageshow="if(event.persisted)noBack();" onunload=""]
...
[/body][/html]
Please replace all "<" and "]" by "<" and ">".
i am getting an error
"non-static method getRootWebBean() cannot be referenced from a static context.
I am able to fix that error.. But back button is still taking me to previous page
Thanks,
Vettri
hi
vettrivelou
can you please tell how you fix that non-static method getRootWebBean() error
Regards
Santhosh Kumar. K
Thanks Mukul ..It worked for me.Awesome
Post a Comment