Friday, September 20, 2013

JS : Warning on Browser Back Button

JS : Warning on Browser Back Button.
This Approach will not disable the browser back button. It will just show the warning message.













**********************************************************

public class PageB {
    private RichForm f1;
    private RichDocument d1;
    private RichDecorativeBox db1;
    private RichPanelHeader ph1;
    private RichCommandButton cb1;
    private RichCommandButton cb2;
    private RichPanelBox pb1;

    public void setF1(RichForm f1) {
        this.f1 = f1;
    }

    public RichForm getF1() {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
        service.addScript(fctx, "window.onbeforeunload = function () { if (logoutAction==0) {return 'Are you sure for going Back:: Neelmani Jaiswal'}; }"); 
        return f1;
    }