0
votes

I have created a new XPage with a DynamicViewPanel that lists the documents in a certain Notes View. Then I have the dynamic view panel configured to show a check box for each row. I then created a button below the dynamic view panel with the plan to select a document(s) with the check box and click on the button to delete them. Below is my Xpages code for the button but why won't this work please?

<xp:button value="Delete" id="delete">

   <xp:this.onclick submit="true" refreshMode="complete">
    <![CDATA[#{javascript:var viewPanel=getComponent  
      ("dynamicViewPanel1");
     var docIDArray=viewPanel.getSelectedIds();
       for(i=0; i < docIDArray.length; i++){
         var docId=docIDArray[i];
         var doc=database.getDocumentByID(docId);
         doc.remove(true);
     }}]]></xp:this.onclick>
</xp:button>

EDIT: Appears to be working now after changing to this below

<xp:button value="Delete" id="delete">
  <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
   <xp:this.action>
     <xp:actionGroup>
       <![CDATA[#{javascript:var viewPanel=getComponent
          ("dynamicViewPanel1");
         var docIDArray=viewPanel.getSelectedIds();
         for(i=0; i < docIDArray.length; i++){
           var docId=docIDArray[i];
           var doc=database.getDocumentByID(docId);
           doc.remove(true);
        }}]]>
      </xp:actionGroup>
     </xp:this.action>
    </xp:eventHandler>
 </xp:button>
2
Make sure you have the correct ACL access. If you haven't built the login functions yet, you will be username "Anonymous". Make sure "Anonymous" has delete access.Steve Zavocki
@SteveZavocki The application has a login facility when I first open it in the browserAJF
@SteveZavocki also, in the ACL I am in the group "Notes developers" and we have delete documents tickedAJF
Did you verify that your array contained the checked documents. Add a print statement in your for loop to write the Unique ID to the log.Steve Zavocki
@SteveZavocki thanks steve will try that ASAPAJF

2 Answers

0
votes

Found a solution and have posted it up as the edited code in the question. Changed the tags in the button element to include an event handler and also included it in an action group tag

0
votes

I know this has been answered - though truth be told I'm not sure I like the code in the answer. No it doesn't "look right". I pasted that in to my designer and it doesn't look right. It should be something like this I'd think:

<xp:button value="Label" id="button3">
    <xp:eventHandler event="onclick" submit="true"
                    refreshMode="complete">
                    <xp:this.action><![CDATA[#{javascript:var viewPanel=getComponent
              ("dynamicViewPanel1");
             var docIDArray=viewPanel.getSelectedIds();
             for(i=0; i < docIDArray.length; i++){
               var docId=docIDArray[i];
               var doc=database.getDocumentByID(docId);
               doc.remove(true);
               }}]]></xp:this.action>
                </xp:eventHandler></xp:button>