1
votes

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

4
I was going to suggest using the RPC control. You can use client code to call a server process directly. It is called "Remote Service" and is in the palette under data access. It is very useful.Steve Zavocki
That's not a bad idea Steve, maybe an answer with a example might help Ben.pipalia
@pipalia, and Ben, I will come up with something. Give me a few minutes. Please try Pipalia's answer and see if it works for you.Steve Zavocki
Have a look at the ExtLib demo database: I think (from the top of my head) you can add an ID of a control as a parameter to the hide method of the dialog. That control will then be refreshed when the dialog is closed.Mark Leusink
Ben, I am curious which solution you went with. If one of these answers, please accept appropriate answer, or if you fixed using your own way method then please add answer. ThxSteve Zavocki

4 Answers

2
votes

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.

1
votes

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.

0
votes

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

0
votes

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>