XPages:dialog box refreshing a panel on close

核能气质少年 提交于 2019-12-11 12:37:53

问题


I have a document that contains a rating custom control (xInvolve, which is excellent!). In this application, administrators want the ability to delete certain ratings for a certain document or all of them (bad ratings on purpose, new version of the document, corrections made to the document ...).

I am showing up the ratings in a view, in a dialog box (the extension Library dialog box, not a Dojo one). In that dialog box, I have a "Delete All" button. That button calls a SSJS function that deletes the rating documents for the document that is currently opened, but I want to refresh the panel that displays the rating, as it should now be empty.

So far, I was able to close the dialog box, but I can't seem to get the panel to refresh. Here's the code for the "Delete All" button:

<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>

The PanelHeader is the panel where the xRating control is inserted.

Should I try putting code in the onClose event of the dialog box? I tried but I didn't get more luck.

Thanks


回答1:


So you can use client side code to achieve this. This is what we do:

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

Hope it helps.




回答2:


Ben,

Here is a solution using the RPC control. This control allows you to call server code directly from clientside javascript. I have frequently used it to call java methods, but haven't used it to call a SSJS function in a library. I make the assumption that it would work the same.

<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>

You would not be able to use getComponent in the RPC, so you would need to pass the UNID. You could pass this to the clientside using a <xp:hiddenInput> when you launch the window. You would close the window in the same manner that you do now (I think).

To call the method of the service, you would use myRPC.callDeleteAllRatings("Open ATM", ""); Again, you call the RPC from clientside.

IMO, once you learn what the RPC can do for you, you wonder how you made due without it.




回答3:


As Mark suggested in a comment above, you should be able to use the onHide property. For example if you wanted to refresh a panel with serverSide id panel1

<xe:dialog id="dialog1" title="Example Dialog"
        onHide=" XSP.partialRefreshGet('#{id:panel1}'); ">

This is working for me




回答4:


Can you not just do a partial refresh? I do that with a simple dialog like so...

<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>


来源:https://stackoverflow.com/questions/30381513/xpagesdialog-box-refreshing-a-panel-on-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!