XPages:关闭时刷新面板的对话框

时间:2015-05-21 18:22:03

标签: xpages xpages-ssjs xpages-extlib

我有一个包含评级自定义控件的文档(xInvolve,非常棒!)。在此应用程序中,管理员希望能够删除某个文档或所有文档的某些评级(故意评级,文档的新版本,对文档的更正......)。

我在视图中显示评级,在对话框中(扩展库对话框,而不是Dojo)。在该对话框中,我有一个“全部删除”按钮。该按钮调用SSJS函数,该函数删除当前打开的文档的评级文档,但我想刷新显示评级的面板,因为它现在应为空。

到目前为止,我能够关闭对话框,但我似乎无法让面板刷新。这是“全部删除”按钮的代码:

<xp:button value="Delete All" id="button1">
                <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
                <xp:this.action>
                    <xp:actionGroup>
                        <xp:confirm
                            message="Are you sure you want to proceed?">
                        </xp:confirm>

                        <xp:executeScript>
                            <xp:this.script><![CDATA[#{javascript:deleteAllRatings(pageDocument.getDocument().getUniversalID());
var c = getComponent("dialogPageRatings");
c.hide("PanelHeader")}]]></xp:this.script>
                        </xp:executeScript>
                    </xp:actionGroup>
                </xp:this.action>
                </xp:eventHandler>
            </xp:button>

PanelHeader是插入xRating控件的面板。

我应该尝试将代码放在对话框的onClose事件中吗?我尝试过,但没有更多的运气。

由于

3 个答案:

答案 0 :(得分:2)

因此,您可以使用客户端代码来实现此目的。这就是我们的工作:

<xp:executeScript>
     <xp:this.script><![CDATA[#{javascript:var strClientCode = "$('#editDeliveryAddressDialog').modal('hide'); window.location.reload();"
view.postScript(strClientCode);}]]></xp:this.script>
</xp:executeScript>

希望它有所帮助。

答案 1 :(得分:1)

钟,

这是使用RPC控件的解决方案。此控件允许您直接从客户端javascript调用服务器代码。我经常用它来调用java方法,但是没有用它来调用库中的SSJS函数。我假设它会起作用。

<xe:jsonRpcService id="jsonRpcService1" serviceName="myRPC"
    pathInfo="rpc">
    <xe:this.methods>
        <xe:remoteMethod name="callDeleteAllRatings">
            <xe:this.script><![CDATA[deleteAllRatings(universalID)}]]></xe:this.script>
            <xe:this.arguments>
                <xe:remoteMethodArg name="universalID" type="string" />
            </xe:this.arguments>
        </xe:remoteMethod>
    </xe:this.methods>
</xe:jsonRpcService>

您将无法在RPC中使用getComponent,因此您需要传递UNID。启动窗口时,可以使用<xp:hiddenInput>将其传递给客户端。您将以与现在相同的方式关闭窗口(我认为)。

要调用服务的方法,您将使用myRPC.callDeleteAllRatings("Open ATM", "");再次,您从客户端调用RPC。

IMO,一旦你了解了RPC可以为你做什么,你就会想知道如果没有它你是如何做到的。

答案 2 :(得分:0)

你能不能只进行局部刷新?我这么做就是这样一个简单的对话......

<xp:button value="Save and Close" id="button2" styleClass="btn btn-primary">
   <xp:eventHandler event="onclick"
   submit="true" refreshMode="partial"
   refreshId="panelRefresh"
   disableValidators="true"
   onComplete="$('#myModal').modal('hide');">
     <xp:this.action><![CDATA[#{javascript:var value:string=getComponent("inputText1").value;
     document1.replaceItemValue("modalTest",value)}]]>
     </xp:this.action>
   </xp:eventHandler>
</xp:button>
相关问题