Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.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 如何从xe:toolbar basicleafnode保存(提交)文档?_Xpages_Xpages Extlib - Fatal编程技术网

Xpages 如何从xe:toolbar basicleafnode保存(提交)文档?

Xpages 如何从xe:toolbar basicleafnode保存(提交)文档?,xpages,xpages-extlib,Xpages,Xpages Extlib,我非常想使用xe:toolbar控件来保存文档,但我不知道怎么做。 我有这个代码,并且发现导航很容易。但是拯救 <xe:toolbar id="toolbar2"> <xe:this.treeNodes> <xe:basicLeafNode href="whereToGo.xsp" label="Save and close"> <xe:this.on

我非常想使用xe:toolbar控件来保存文档,但我不知道怎么做。 我有这个代码,并且发现导航很容易。但是拯救

<xe:toolbar
    id="toolbar2">
    <xe:this.treeNodes>
        <xe:basicLeafNode
            href="whereToGo.xsp"
            label="Save and close">
            <xe:this.onClick>
                <![CDATA["<WHAT GOES HERE?>"]]>
            </xe:this.onClick>
        </xe:basicLeafNode>
    </xe:this.treeNodes>
</xe:toolbar>

问题是您只有客户端onClick。您可以从客户端调用ssjseventhandler,如

对于这个示例,我使用了Jeremy提供的完整executeOnServer脚本,但我认为您可以稍微修改一下。我还使用了完全刷新,如果不想刷新整个页面,也可以使用部分刷新

    <xe:toolbar
        id="toolbar2">
        <xe:this.treeNodes>
            <xe:basicLeafNode
                href="whereToGo.xsp"
                label="Save and close"
                onClick="executeOnServer('saveDocument');">
            </xe:basicLeafNode>
        </xe:this.treeNodes>
    </xe:toolbar>

    <xp:scriptBlock>
        <xp:this.value><![CDATA[

    var executeOnServer = function () {
        if (!arguments[0])
            return false;

        var functionName = arguments[0];
        var refreshId = (arguments[1]) ? arguments[1] : "@none";
        var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];
        var options = (arguments[2]) ? arguments[2] : {};
        dojo.query('[name="$$xspsubmitid"]')[0].value = form.id + ':' + functionName;
        XSP._partialRefresh("post", form, refreshId, options);

    }
]]></xp:this.value>
    </xp:scriptBlock>

    <xp:eventHandler event="saveDocument" submit="false"
        id="saveDocument">
        <xp:this.action>
        <xp:actionGroup>
            <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:println("save")}]]></xp:this.script>
            </xp:executeScript>
            <xp:save></xp:save>
        </xp:actionGroup>
    </xp:this.action>
    </xp:eventHandler>


另一种方法是(正如Oliver已经提到的)使用隐藏分区中的真实按钮。

basicLeafNode的onClick事件仅适用于客户端JS。您需要使用每个basicLeafNode的submitValue属性,然后将SSJS添加到outline控件的onItemClick事件中。然后可以使用context.getSubmittedValue()检查单击了哪个节点,然后采取相应的行动


请看我的答案:

这是我最后做的事情。 Per的建议导致对工具栏的onItemClick事件进行调查,结果证明非常简单。 感谢大家的贡献

<xp:this.data>
    <xp:dominoDocument
        var="docPrognosis"
        formName="prognosis"
        computeWithForm="onsave">
    </xp:dominoDocument>
</xp:this.data>
<xe:toolbar
    id="toolbar1">
    <xe:this.treeNodes>
        <xe:basicLeafNode
            label="Save"
            submitValue="save">
        </xe:basicLeafNode>
    </xe:this.treeNodes>
    <xp:eventHandler
        event="onItemClick"
        submit="true"
        refreshMode="complete">
        <xe:this.action>
            <![CDATA[#{javascript:
            if (context.getSubmittedValue() == "save") {
                if (docPrognosis.save()) {
                    context.redirectToPage("prognosisview.xsp");
                }
            }
        }]]></xe:this.action>
    </xp:eventHandler>
</xe:toolbar>


如果要使用简单操作(保存文档),则:设置工具栏并使用提交值=“保存”保存节点,然后在简单操作中添加一个操作组,条件公式为:context.getSubmittedValue()=“保存”。现在为这个操作添加简单的操作。

不是真正的解决方案,但每次我只有一个简单的“onClick”,我就会执行一个CSJS,它会得到一个“real”按钮(放在一个隐藏的DIV中)并单击它。真正的按钮,然后可以编程麻省理工学院SSJS或任何其他行动。是的,我见过这个使用。除非绝对必要,否则我不想去那里。但是谢谢!:-)你真的需要一个隐藏的按钮吗?对于主窗体,您可以不使用form.submit()。不,您只需要一个可以从客户端触发的eventHandler,我之前提到过捕获所有提交的子值并遍历它们,因为我可以重用eventHandler。