Xpages 如何在 SSJS 中获得 CSJS 确认 [英] Xpages how to get CSJS confirmation in SSJS

查看:27
本文介绍了Xpages 如何在 SSJS 中获得 CSJS 确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个重复控件,其中包含一个按钮,用于处理用户选择的文档.我的第一个用例是删除.我使用 view.postScript 检测用户是否选择了至少一个文档,如果没有选择,则发布错误消息.

I have a repeat control that contains a button that will process documents that a user selects. My first use case is for deletions. I detect whether or not the user selects at least one document and post an error message if they do not, using view.postScript.

我想添加一个确认对话框,确认用户想要对文档执行操作(例如删除它们)但找不到方法.

I want to add a confirmation dialog box, confirming that the user wants to take the action on the documents (like delete them) but cannot find a way to do it.

理想情况下,我想在我当前的 SSJS 中完成这一切.

Ideally I want to do this all in my current SSJS.

我的代码在下面,其中有一个存根,用于要求用户确认.

My code is below, with a stub in for where I want to ask the user for confirmation.

任何帮助将不胜感激.

//Did the user select a document
var hasSelected:Boolean = false;
for (var id in SelectedDocs.getSelectedIDs()) {     
        hasSelected = true;
        break
}

//If false then set a warning
if (hasSelected == false)
{
x="alert('Error\\n\\nPlease select one or more documents to delete.\\n\\n');";
view.postScript(x)
return
}

//If true then ask confirmation
if (hasSelected == true)
{
}

var rspView:NotesView = database.getView("(dbAllRpPCTasks)")

for (var id in SelectedDocs.getSelectedIDs()) {     

        //Get each selected doc
        var doc:NotesDocument = database.getDocumentByID(id);

        //Get child docs and delete them
        var key:String = doc.getItemValueString("ID");
        var dc:NotesDocumentCollection = rspView.getAllDocumentsByKey(key);
        if (dc.getCount() != 0) 
            {dc.removeAll(true);}

        //Delete the selected doc
        doc.remove(true)
        doc.recycle();
        SelectedDocs.setSelectedState(id,false);
}

感谢所有的建议.我正在回应弗兰克的回答.尝试编写 CSJS 来确定用户是否选择了文档,然后继续.

Thanks for all the suggestions. I am responding to Frank's answer. Trying to write CSJS that will determine if the user selected docs and then proceed or not.

在 CSJS 中我的按钮的点击事件中,我有以下内容:

In the on click event of my button in the CSJS I have the following:

var dtList = document.getElementsByName("#{id:dataView1.getSelectedIds()}");
confirm("What is the length?" + dtList.length);
confirm("Can I get an item?" + dtList.item(0));

它返回长度为零并且项目未定义.

It returns a length of zero and the item is undefined.

推荐答案

与 LotusScript 不同,XPage 代码不能等待用户输入.把它想象成调用一个代理在服务器上运行并在其中添加一个 UIWorkspace.prompt()(这会抛出错误,因为不允许用户交互).

Unlike LotusScript, XPages code cannot wait for user input. Think of it like calling an agent to run on server and adding a UIWorkspace.prompt() in there (which will throw an error, because user interaction is not allowed).

最好的建议是将确认提示作为 CSJS 添加到用户最初单击的按钮中,例如

The best recommendation would be to add the confirmation prompt as CSJS to the button the users are initially clicking, e.g.

return confirm("Are you sure?");

如果他们选择了文档,他们会在继续之前收到提示.如果没有,它可能会提示一些用户选择文档.如果用户没有选择任何文档,点击他们想要继续,然后抱怨又收到另一个对话框,那么很难对他们的抱怨表示同情.

If they've selected documents, they'll be prompted before they continue. If they have not, it might prompt some users to select the documents anyway. It's hard to have sympathy with complaints from a user who didn't select any documents, clicked that they wanted to continue, then complains at getting another dialog.

这篇关于Xpages 如何在 SSJS 中获得 CSJS 确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆