当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Close XPages ExtLib dialog from inside iframe

问题描述:

I have db1.nsf/doc1 open in an XPage. On the XPage is a view of of related documents (db2.nsf/doc2) on the same server. I am using a repeat control with a link wrapped around each entry to open doc2 in an ExtLib dialog.

Note: Because doc2 has fileUpload and fileDownload controls on it, I have to open doc2 in an iframe in the dialog (v8.5.3). I have all the file upload/download stuff working thanks to Toohey's article File Upload XPage Forms via OpenNTF.org Extension Library Dialogs.

The problem is that I am unable to close the dialog with a button in the iframe in the dialog. The difference between my scenario and Toohey's is that I am working with 2 different documents in 2 different databases. The parent opener is an XPage with datasource doc1 in db1 while the dialog child is doc2 in db2. I don't seem to be able to get a handle on the parent document from within the child document in the iframe so i can close the dialog. It looks something like this:

<html><body>

<form action="db1.nsf/mainDoc.xsp?doc1&action=openDocument"></form>

<div id="dialog">

<form action="db1.nsf/mainDoc.xsp?doc1&action=openDocument">

<iframe src="showDialog.xsp?databaseName=db2.nsf&doc2">

<html><body>

<form action="db1.nsf/showDialog.xsp?databaseName=db2.nsf&doc2&action=editDocument">

<button id="okBtn" type="submit">OK</button>

</form>

</body></html>

</iframe>

</form>

</div>

</body></html>

*Note: showDialog.xsp is an XPage in db1 with it's datasource being db2.nsf/doc2. (I'm using xp:panel with tagName="iframe".)

I want the OK button to save the document (which it does) and close the dialog (which it doesn't). I have tried several different methods of "parent. ..." to get a handle on and close it - with no success at all.

How do I get a handle on the dialog element from within the iframe so I can close it?

*Added server version.

网友答案:

The way the XPages Extension Library dialog works is that it runs SSJS, then calls view.postScript() to pass CSJS back to the browser to close the dialog. You need to reproduce that. (I'm not sure what server version you're using but view.postScript() was only added in 8.5.3, probably for the dialog use case.)

I'm not familiar with the functionality you're using, but 9.0.1 provided the ability to upload attachments within a partial refresh, which resolves workarounds for Ext Lib dialogs.

The databaseName property of a datasource can be computed (format is serverName!!filePath), so data being in a separate database should not be an issue. Indeed most applications I build now separate XPages into one NSF and data / forms / views / agents in another. That application architecture is required anyway for XPages on Bluemix, and standard for other web application development.

分享给朋友:
您可能感兴趣的文章:
随机阅读: