Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xpages保存新创建的文档后获取URL_Xpages - Fatal编程技术网

xpages保存新创建的文档后获取URL

xpages保存新创建的文档后获取URL,xpages,Xpages,我正在寻找一个文档的URL链接。对于现有的文档(已经保存,当我打开它们时-我用UNID获取url),没关系,我的问题是当我想获取新创建文档的url时-我没有在url中获取UNID。(仅限,例如:http://myserver/ournsf/doc.xsp?action=newDocument,不带UNID) 我的代码是这样的: if(docSource.isNewNote()){ docSource.save(); } empbody.appendText(con

我正在寻找一个文档的URL链接。对于现有的文档(已经保存,当我打开它们时-我用UNID获取url),没关系,我的问题是当我想获取新创建文档的url时-我没有在url中获取UNID。(仅限,例如:
http://myserver/ournsf/doc.xsp?action=newDocument
,不带UNID)

我的代码是这样的:

if(docSource.isNewNote()){
        docSource.save();
    }
    empbody.appendText(context.getUrl().toString())
谢谢你的时间

context.getUrl()
只提供当前URL。它不包含documentId,因为您在案例中创建了一个新文档

您正在寻找将使用当前XPage打开当前文档的URL。您可以通过以下方式获得:

var thisdoc = docSource.getDocument(true);
var url = facesContext.getExternalContext().getRequest().getRequestURL().toString() + 
          "?action=editDocument&documentId=" + thisdoc.getUniversalID());

您可以使用数据源的postSaveDocument事件从UNID-like计算URL

var url = "page.xsp?action=openDocument&documentId="+document1.getDocument().getUniversalID();
document1.setValue("url", url);
document1.save();

您可以通过以下方式获取新创建文档的url:

document1.getDocument().getUniversalID()
此处document1是文档的数据源名称。 如果要在保存后重定向到新创建的文档,可以在导航规则中使用此代码或添加以下XML:

<xp:this.navigationRules>
    <xp:navigationRule outcome="xsp-success">
       <xp:this.viewId><![CDATA[#{javascript:return "XPageName?documentId="+document1.getDocument().getUniversalID()+"&action=editDocument"}]]>      
    </xp:this.viewId>
    </xp:navigationRule>
</xp:this.navigationRules>


其中XPageName是XPage的名称。

@KnutHermann:你的答案对我有用……谢谢,它有用。我刚更改了?action参数,我正在寻找读取模式。