xpagesxpages-ssjs

facesContext.getExternalContext().getRequestPathInfo(); no longer working


I've added the following in the xpages beforePageLoad to return the url path:

var url = facesContext.getExternalContext().getRequestPathInfo();

This was working in prior versions of Domino, but returns a null on my current 12.0.2 Domino server.

I'm accessing the facesContext in the beforePageLoad so that I can lookup the unid for the document to load prior to the xpage loading. Any ideas on why this is not working or a workaround?


Solution

  • You can use getRequestPathInfo()to access the part between the .xsp and the query parameters (and not the file path including the .nsf itself). The documentation says: "Return the extra path information (if any) included in the request URI; otherwise, return null."

    So this will return null: /folder/db.nsf/xpage.xsp, while this will return "/test": /folder/db.nsf/xpage.xsp/test

    You can use facesContext.getExternalContext().getRequestContextPath() to get the folder/file path of the request.


    If the unid is sent as a query parameter in the URL, you can do this to get hold of the unid value (assuming the parameter for the unid is called 'unid'):

    var unid = param.get("unid");