2
votes

I have a mobile XPages application which uses the single page application control (xe:singlePageApp) of the XPages extension library. The application also uses a workflow engine which sends out emails with links to documents to users so they can approve requests.

The link URL is composed like

http://hostname/app.nsf/m_page.xsp?action=openDocument&documentId=2A2A#requestForm

where requestForm is the name of the appPage containing the form to display a single request document.

If the user is already logged in, the browser opens and displays the document as intended.

However, if the user is not already logged in, the Domino login form is displayed (session based authentication). When the user then logs in, the same XPage is opened, but to the default page (selectedPageName attribute of the singlePageApp) instead of the appPage with the pageName requestForm. The reason for this behavior is that after submitting the login form the anchor part (#requestForm) is no longer present in the URL the browser is redirected to because the #requestForm-part is never sent to the server where the redirect URL is computed in the first place.

Possible solutions I can think of are

  • put the intended pageName in a real URL parameter (like documentId), parse the URL and modify the browser location (from ...&documentId=2A2A&pageName=requestForm to ...&documentId=2A2A#requestForm)
  • check the URL for the existence of the documentId parameter and modify the browser location (add #requestForm) if it is present
  • modify the Domino login form as per Jake Howlett's Suggestion (which is a not always permitted)

I was wondering now if there are more elegant solutions to this.

1

1 Answers

1
votes

I would take the first option in your case. But instead of handling the url change at the client-side, I would handle this on the server-side. Otherwise, client will load the initial page once and submit an additional request to the server.

On the beforePageLoad event:

var url:XSPUrl=context.getUrl();

if(url.hasParameter("pageName")) {
    var pageName=url.getParameter("pageName");
    url.removeParameter("pageName");
    facesContext.getExternalContext().redirect(url.toString()+"#"+pageName)
}

This will do the redirection before loading the page.