SSJS之后的客户端消息例程如何?
我有一个在 SSJS 中发送和发送电子邮件的按钮...
现在我想如果可以向用户实时显示发送电子邮件的状态:
- 发送过程....
- 发送成功或发送错误
我如何调用来自 SSJS 例程的 JS 客户端代码? 你有什么建议吗?
I have a Button that in SSJS send and Email...
Now I would if is possibile show the status of sending of email in real-time to the user:
- sending process....
- sending Successful or sending error
How Can i call a JS client codice from SSJS routine?
Have you any suggest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 ExtLib,那么您还可以使用 @WarningMessage('messageText') 方法。
您需要向 XPage 添加一个部分来显示消息。它可以很简单,
一旦添加,每次调用 @WarningMessage 都会在消息窗格中添加一行。
If you are using ExtLib then you can also use the @WarningMessage('messageText') method.
You will need to add a section to the XPage to display the messages. It can be as simple as
Once added each call to @WarningMessage will add a line to the messages pane.
8.5.3 引入了一个非常好的方法:
您可以从 SSJS 代码中插入任何您喜欢的 CSJS 代码。
8.5.3 introduced a very nice approach:
you may insert any CSJS code you like from the SSJS code.
这非常简单。
1. 在页面上添加隐藏输入控件,并记下 id。
2.在你的SSJS中使用 getComponent("inputHidden1").setValue("This is the message")
3. 确保隐藏输入控件位于正在刷新的区域中(否则该值不会传回浏览器,因此无法在 CSJS 中访问)
4. 转到“源”窗格并将光标放在触发 SSJS 的事件处理程序上或其中。您需要执行此操作才能到达 onComplete 事件
5. 在“所有属性”面板中转到 onComplete,在那里添加您的 CSJS。例如alert(dojo.byId("#{id:inputHidden1}").value)
这将运行您的SSJS,并在完成后用字段中的任何代码提醒用户。
有关演示和演示代码,请查看我的博客文章: http://www.intec.co.uk/xpages-calling-client-side-javascript-from-server-side-javascript/
This is quite straightforward.
1. Add a Hidden Input control on your page, noting the id.
2. In your SSJS use getComponent("inputHidden1").setValue("This is the message")
3. Ensure the Hidden Input control is in the area being refreshed (otherwise the value doesn't get passed back to the browser, so can't be accessed in CSJS)
4. Go to the Source pane and place the cursor on or in the eventHandler that is triggering your SSJS. You need to do this to get to the onComplete event
5. In All Properties panel go to onComplete, add your CSJS there. e.g. alert(dojo.byId("#{id:inputHidden1}").value)
This will run your SSJS and on completion alert the user with whatever code is in the field.
For a demo and demo code, check out my blog post: http://www.intec.co.uk/xpages-calling-client-side-javascript-from-server-side-javascript/
除了 Paul 的答案之外,另一种方法是使用 extlib 中的对话框,您可以从 ssjs 调用它,在对话框中放置一个字段并将其设置为范围值并显示对话框。
Another way to do it besides Pauls answer is to use a dialog from the extlib, and you can call it from ssjs, put a field in a dialog and set it to a scope value and show the dialog.