【问题标题】:How to pass the Document context in Xpages while calling an Agent?调用代理时如何在 Xpages 中传递文档上下文?
【发布时间】:2012-03-09 10:59:12
【问题描述】:

在调用代理时如何在 Xpages 中传递文档上下文?在 Xpage 中,我需要从我的 Xpage 调用带有 documentcontext 的 java 代理,而且我需要将当前文档作为参数传递...

在 Lotuscript 中我们可以很容易地做到这一点而无需保存当前文档,但在 Xpage 中我使用以下代码。document1 是当前文档。

var agent=database.getAgent("AgentName");
agent.runWithDocumentContext(currentDocument.getDocument());

此代码我无法获取当前文档项目的值,但如果我将使用以下代码,

var agent=database.getAgent("AgentName");
document1.save();
agent.runWithDocumentContext(currentDocument.getDocument());

我可以获取当前文档的item值...但是我不想保存文档,不保存文档我需要获取item的item值。

请为此提供任何好的解决方案...

【问题讨论】:

  • 不应该吗? : agent.runWithDocumentContext(document1);
  • 是的,这会引发错误...之后我尝试了 document1.getDocument() 方法
  • 啊哈,我没有看到你的重新编辑。您无法在文档上调用后台代理,因为代理在服务器上运行并且您的文档在前端网站中打开,因此之前尚未在网络上保存过。服务器不知道,你的文档甚至存在...
  • 什么触发了你的代码?按钮?
  • 您是否尝试过 getDocument(true),是什么将更改的字段从数据源传递到后端文档?

标签: lotus-notes xpages xpages-ssjs


【解决方案1】:

agent.runWithDocumentContext(currentDocument.getDocument(true))。这会将所有新值放入后端文档中,因此它的工作方式与 lotusscript 相同。此外,如果您需要使用注释表单计算当前文档,请将数据源的“computewithnotesform”属性设置为“onload”或“both”。

【讨论】:

  • Ferry 非常好。,我可以得到我的物品的价值
【解决方案2】:

由于 xPage 上可以有多个文档源,所以我使用 ParameterDocID...

var id = document1.getDocument().getNoteID();
var agent = database.getAgent("MyAgent");
agent.run(id)

在代理中...

Call GetDocument(agent.ParameterDocID)

...

Public Sub GetDocument(DocID As String)
On Error GoTo eh

Set Doc = Db.GetDocumentByID(DocID)

es:
Exit Sub
eh:
Resume es
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 2018-12-28
    • 1970-01-01
    • 2021-12-19
    • 2014-12-16
    • 1970-01-01
    相关资源
    最近更新 更多