1

I have a repeat control setup which contains a table. The table row(s) contain information from an entry in a view. When the user clicks on the entry, it will redirect them to another xPage which contains the information pertaining to the item they clicked.

I noticed that if you click the browser back button (in this case mobile iPhone Safari), it will redirect you to the previous page, but the onClick events do not fire if you click a row in the repeat control.

I'm not exactly sure what is causing this to break, but has anyone run into this in the past or have any idea no what may fix this issue?

var entry:NotesViewEntry = data; 
var docId = entry.getDocument().getUniversalID(); 
var url = context.getUrl().getAddress().replace(view.getPageName(), '');

context.redirectToPage(url + "/xCall.xsp?documentId=" + docId + "&action=openDocument"); 

Edit:

The issue appears to only occur when using mobile Safari (for iPhone). It works fine in Chrome/Internet Explorer.

Another interesting detail, if you click on an item and it redirects you to a page, then you click the browser back button, you can click on the repeat control and nothing happens. However if you way 15-20 seconds and then click, it works like expected. If you click anytime before 15-20 seconds, nothing happens

Second Edit:

I ended up coming across this link: https://github.com/christophery/pushy/issues/51 which described a problem where the browser back button was creating weird behavior. I ended up using the following code which seems to have fixed the issue.

// for jQuery
$(window).bind("pageshow", function(event) {
    if (event.originalEvent.persisted) {window.location.reload();}
});

// for regular JS
window.onpageshow = function(event) {
    if (event.persisted) {
        window.location.reload() 
    }
};

1 Answers1

0

This might be caused by the browser caching the previous page. Add this to the beforePageLoad event of your XPage in order to tell the browser not to cache the page:

<xp:this.beforePageLoad><![CDATA[#{javascript:
    // Do not cache the HTML pages in the browser
    var exCon = facesContext.getExternalContext();
    var response=exCon.getResponse();
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Cache-Control", "no-store");
}]]></xp:this.beforePageLoad>
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
  • I tried this and it did not appear to work, but I noticed some other details while trying this... The issue appears to only occur when using mobile Safari (for iPhone). It works fine in Chrome/Internet Explorer. Another interesting detail, if you click on an item and it redirects you to a page, then you click the browser back button, you can click on the repeat control and nothing happens. However if you way 15-20 seconds and then click, it works like expected. If you click anytime before 15-20 seconds, nothing happens. – user3641366 Aug 01 '18 at 19:30