Error when opening an XPage - cannot load document - xpages

Am coming across an intermittent problem when opening an Xpage. I have a button on a dialog to open another XPage in a new browser window, the code in the button is
var path = facesContext.getExternalContext().getRequest().getContextPath();
var xpage = "Claim.xsp"
var fullpath = path + "/" + xpage;
var url = fullpath + "?action=openDocument&documentId="+ Action.claimDocID
view.postScript("window.open('" + url + "')"
(if anyone has another way instead of the view.postScript let me know, just couldn't figure out how to open in a new browser window)
Occasionally when the window opens I'll get an error - Could not open document, below is the entry in the log.
05/04/2017 08:26:10 AM HTTP JVM: CLFAD0131E: Unable to push data because: Could not open the document. For more detailed information, please consult error-log-0.xml located in C:/IBM/Domino/data/domino/workspace/logs
05/04/2017 08:26:10 AM HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: com.ibm.xsp.FacesExceptionEx: Could not open the document
CLFAD0131E: Unable to push data because: Could not open the document com.ibm.xsp.FacesExceptionEx: Could not open the document at com.ibm.xsp.model.domino.DominoDocumentData.doOpenDocument(DominoDocumentData.java:529) at com.ibm.xsp.model.AbstractDocumentDataSource.openDocument(AbstractDocumentDataSource.java:148) at com.ibm.xsp.model.AbstractDocumentDataSource.load(AbstractDocumentDataSource.java:100) at com.ibm.xsp.model.AbstractDataSource.getDataContainer(AbstractDataSource.java:474) at com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(DominoDocumentData.java:165) at com.ibm.xsp.model.AbstractDataSource.pushData(AbstractDataSource.java:576) at com.ibm.xsp.util.DataPublisher.publishControlData(DataPublisher.java:181) at com.ibm.xsp.component.UIViewRootEx.publishControlData(UIViewRootEx.java:1288) at com.ibm.xsp.component.UIViewRootEx.initBeforeContents(UIViewRootEx.java:1615) at com.ibm.xsp.page.compiled.AbstractCompiledPage.init
<-- is from the error-log-0.xml
BUT, when I press reload on the browser the page loads, so the URL is correct. I placed all sorts of print statements on the XPage, in the Java managed bean it also uses, and when the error occurs nothing is printed. The error is immediate, whereas when reloading it takes time and the messages are printed. After the first error, it doesn't occur again.
A couple of other things about this application, it is password protected, it is running on HTTPS. The XPage it loads does have a Notes document that's located in another database plus it uses a Managed bean. If anyone has any ideas be grateful.
Thanks
Cameron

In regards to opening a given page in a new tab: have you tried using a link control instead of a button? Set a computed target url (preferably under "All Properties >> data >> value") AND set the target property to "_blank" ("All Properties >> basics >> target")
Using css you can later on modify the link to look like a button, if that's needed.
Btw: in general there's no need to calculate the path if you stay within the same database; the XSPcontext sees the .nsf as a common root. Just have your url point to "/myNewPage.xsp" then add the query string accordingly, like
var url = "/" + xpage + "?action=openDocument&documentId="+ Action.claimDocID

This error happens when universal ID provided to documentId URL parameter is invalid - possibly a document from another database or user has no access to it (readers field).

Just use a link with a target="_blank" parameter:
<xp:link value="/my_page_name.xsp" text="to the infinity and beyond" target="_blank">
<xp:this.parameters>
<xp:parameter name="action" value="openDocument" />
<xp:parameter name="documentId" value="#{Action.claimDocID}" />
</xp:this.parameters>
</xp:link>

I have same error. In My Case I was remove field In Shared Elements. After Field was restored, error is disappear.

Related

Domino Document cannot be opened twice on public access xpage

I have an Xpage with access set to public for clients to fill in a form. When I send the client the link to the page and they open it for the first time. Everything runs smoothly. However, if they close the browser and click on the link again they receive this error:
{Unexpected runtime error
The runtime has encountered an unexpected error.
Error source
Page Name:/xpClientForm.xsp
Exception
Could not open the document
Invalid universal id}
I am using a switch facet to cycle between forms depending on the client type.
The domino document id is being stored in a sessionScope beforepageload and the document dynamically computes it based on that sessionScope variable.
Here is the code:
SessionScope assignment on beforepageload
var cData = getClientData(id);
sessionScope.docId = cData.docID;
Document datasource
<xp:panel style="height:100px" id="pnlDocData">
<xp:this.data>
<xp:dominoDocument var="document1"
formName="frmA" action="editDocument"
documentId="#{javascript:sessionScope.docID;}" scope="request">
</xp:this.data>
</xp:panel>
However when i execute this custom control on a page that does not have public access. It runs fine with no issues irrespective of how many times i open the link.
Any help will be greatly appreciated.
You need to set ignoreRequestParams="true" on the dominoDocument datasource. Otherwise it's using the document ID in the URL or trying to create a new document, which the user probably doesn't have access to do.
Computing the document ID is the less common scenario, which is using the URL for document location is the default.

Error accessing Xpage using $$OpenDominoDocument.xsp method on database replica

I have a Form called 'Contact Level\Customer Contact | Customer Contact', which is a response document, and in the properties I have associated the customerContact XPage to the form. In all view panel controls I have use the 'XPage associated with the document's form' property.
On server A the XPage is opened correctly using the $$OpenDominoDocument.xsp method from any view control.
On server B, which has a replica of the server A database, the XPage does not open from any of the views using the $$OpenDocumentDocument.xsp method. The error I see on the server log is 'HTTP Web Server: Item Not Found Exception [db.nsf/$$OpenDominoDocument.xsp?documentId=......&action=openDocument]'.
I have removed sections of code from the XPage to track down whereabouts the error is happening and it was the domino document settings that cause the problem.
I have checked the form properties and they are correct.
If I change the $$OpenDominoDocument.xsp section of the URL to customerContact.xsp then the document opens without error.
If I change the view panel property to explicitly open the customerContact XPage then again the document opens without error.
I have tried changing the form and XPage so it opens the 'contact' XPage instead (an almost identical non-response version of the same form) and the XPage still errored.
I tried saving a document in client but the XPage still errored.
I changed the form name to include a new alias of CustomerContact and modified a document to use the new form name, and this document opened without error. That made me wonder if the space in the Customer Contact name was causing the error, but there are many forms / XPages on the database in question, some others with spaces in there alias, and this is the only form that errors.
Any help would be greatly appreciated.
Is there another Form or Subform that has the same name or has "Customer Contact" as an alias? I have a feeling I read a blog some time ago that mentioned $$OpenDocument picking up a subform instead of a form, but I'm not 100% sure, so that may be wrong. If it's working on a newer server, that issue may have been fixed.

404 Item not found When Providing access to existing documents from an XPage View

I have been following the tutorial here for creating an XPage application. Unfortunately I am encountering an Error 404 HTTP Web Server: Item Not Found Exception when you try to follow a link to another document from the main view XPage. Everything else seems to function properly until that point.
It happens when you select "XPage associated with the documents form".
According to some googling I simply needed to rebuild my project but that didn't work. That was the only fix I was able to find.
The link for my xpage for my view is : http://localhost/ExpenseClaims.nsf/xclaimsview.xsp
The link to a xpage with the 404 error from my view is: http://localhost/ExpenseClaims.nsf/%24%24OpenDominoDocument.xsp?documentId=15DA9966C77908D385257C150070483D&action=openDocument
The problem has returned for my "claim" xpage that represents a form document named "claim". My response documents open as needed.
My associations are:
Views: Xpage:
Claims -> xclaimsView
Forms: Xpage:
claim -> claim
response -> response
Most likely the connection between your XPage and the form didn't work. Open the form, then in the properties pick the XPage you want to open. Save it and try again.
There's one special case when you have an XPage with the same name as the form, where that should happen automatically, but it is safer if you specify the property in the form (second tab on the property box)
The data connection from the xpage to the form seems to be breaking down that's a possible cause but not an acceptable answer. The reasons are everything from the project build being broken to the port that domino designer is using as default being occupied.
Cleaning then building the project may help (Project -> Clean) but in my case it didn't. Opening the Page by selecting it by name is helpful but not if you are opening two different pages from the same view(View Properties -> at run time open selected document). There was another suggestion that said to move the default domino test port(File -> Preferences -> Domino Designer) but that didn't work for me.
The final answer was to go to each form's properties box and link it to it's corresponding xpage (second tab form properties). (see answer marked as correct for a link to IBM with a better explanation)

Unable to get document page name for

I have a view that has XPage Associated with document form set.
The form property has the xpage associated with the document.
If I click on the link in the view the proper correct xpage is displayed as expected.
But if I close the browser, and paste the URL to the document into the browser, I get the error, Unable to get document page name for (and the unid). As long as I remain logged in the url will work without error or if I set anonymous to Reader the url will continue to work. But if I close the browser where I would be prompted to login then I get the error but I get the error before being prompted to log in.
The url for assocated forms looks a little different than when the view is used to display the xpage.
myserver/mydb.nsf/$$OpenDominoDocument.xsp?documentId=12B571F2B03E3764852573690041E273&action=openDocument
The view has various types of forms so I need to associate the form with the xpage or I suppose I can compute the xpage for the form. But any idea what would be causing this issue?
If you are opening a document from a view, the associated form could be overriden by a form formula of the view. When opening the document directly with $$OpenDominoDocument.xsp the original form stored in the document is used instead.
The form can be associated with a XPage in different ways:
For XPiNC there is a field $XPagesAltClient in the form
For web access there is a field $XPagesAlt in the form
There is a entry in the xsp.properties file.
For example this entry...
xsp.domino.form.xpage.foo=bar
...will open a document with the value foo in the Form field with the XPage bar.xsp.
Hope this helps
Sven

XPages: execute context.redirectToPage after client side function?

Why does context.redirectToPage behave differently when executed in a view root-event instead of an event handler?
This question came up when I tried to set the language of an xpages application to the language saved in the user profile, once the user is logged in. I use a properties-file with translated strings in a resource bundle, and retrieve the strings like this:
<xp:text value="${langString['WELCOME_TEXT']}" />
When the language is changed and so a different properties-file is loaded, the page needs to be refreshed in order to update those strings. This worked fine when I added a full-refresh event handler to the login button, that executed a server side context.redirectToPage(). No luck with client side refreshes like location.reload or window.location.href=window.location.href (the login-function itself is a client side function though).
But of course the user expects that he is also logged in when he presses the enter key instead of the button after he has entered his credentials. So I added an onkeypress-event to the username and password input fields, and checked for the enter key (if (thisEvent.keyCode==13) dosomething...) before executing the login function.
But now the event handler is called every time a key is pressed and of course I do not want the context.redirectToPage to be executed all the time.
Thus I removed the server side event handlers and changed the login function so that it terminated with a partial refresh of the div containing the whole page:
var p = {"execLogin":"true"}; XSP.partialRefreshPost( '#{id:wholePage}', {params: p} );
The parameter sent via the partial refresh now triggers an event in which our context.redirectToPage is executed:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:if (param.containsKey('execLogin') && param.get('execLogin').toString().equals('true')) {
print("test");
context.redirectToPage(context.getUrl().toSiteRelativeString(context),true);
}}]]></xp:this.beforeRenderResponse>
The page is refreshed and "test" is printed out, but I still see the old language strings. I have to refresh the page manually again to make the new user language take effect.
Any idea how to execute a genuine full refresh this way, or maybe another way to update the strings retrieved from the property bundle?
Thanks in advance. Regards,
Sarah
EDIT
I now have:
<xp:inputText id="cc_login_panel_login_username" styleClass="span2">
<xp:eventHandler event="onkeypress" submit="true" refreshMode="complete">
<xp:this.script><![CDATA[if (thisEvent.keyCode!=13) {
return false;
} else {
doLogin();
return true;
}]]></xp:this.script>
<xp:this.action><![CDATA[#{javascript:context.redirectToPage(context.getUrl().toSiteRelativeString(context));}]]></xp:this.action>
</xp:eventHandler>
Because context.reloadPage() didn't even log me in somehow (strange) I got back to using redirectToPage. The server side event is fired once and at the right time *thumbs up*, but the language properties-bevaviour is still the same.
$ is only set on page load, whereas # is set each time during the partial refresh.
I don't think a partial refresh will work at all though. This will refresh the computed field. However, it will need a full refresh to refresh the part of the XPage that includes the properties file. In other words, you would be refreshing the computed field, but using the same properties file.
I wonder if context.redirectToPage or context.reloadPage is somehow going to the same page but with the cached properties files.
If you're always wanting to come back to the same page, a full refresh instead of partial refresh may be the best option.
I think this has something to do with using the $ parameter. this tells the runtime to retrieve the language file the first time the current page is created in the back-end. When a user does a refresh it is actualy retrieving a saved version of the page you are viewing.
I see you're calling "context.redirectToPage(context.getURL().toSiteRelativeString(context)))" within an xp:this.action tag for the xp:eventHandler.
Try using xp:this.onComplete in place of xp:this.action.
According to the Designer tooltip for the action, the expected return is a string to be passed to the navigation handler. So instead giving the onComplete will execute the redirect command when it's done with the eventHandler group of events.
Thanks for all the helpful answers, in fact all of them did work, the problem turned out to be my misunderstanding of when the properties-file is loaded. It is loaded in an early phase, long before my new language is set to the sessionScope (that sessionScope variable is then used as a part of the name of the properties-file to be loaded, via the VariableResolver).
Now I use a double full refresh to load the new file. When the login function terminates successfully, it executes:
window.location.href = window.location.href + "?doRefresh=true";
And to the view root element I added the following event:
<xp:this.beforeRenderResponse><![CDATA[#{javascript:
if (context.getUrlParameter("doRefresh")!=null&&context.getUrlParameter("doRefresh").equals("true")) {
var url = context.getUrl().toSiteRelativeString(context);
url = url.replace("?doRefresh=true","");
context.redirectToPage(url);}
}]]></xp:this.beforeRenderResponse>
This is not a very sophisticated solution, but at least it works :-)

Resources