title: xpages save / cancel actions scenario
body: <p>I will describe shortly my little project application:</p>
  
  <p>the main doc. content is <code>Cdoc</code> ( datasource which contains fields + a button ). This button displays a dialog which is <code>Pdoc</code> ( a datasource ) - before showing the button I will save the doc. to get the UNID and then I will pass it to the <code>Pdoc</code>, I want to link the <code>Cdoc</code> and <code>Pdoc</code> with the UNID.
  My button which shows the dialog:</p>
  
  <pre><code>&lt;xp:button value="Adding Pdoc from the dialog" id="button3"
          styleClass="lotusFormButton" refreshMode="partial"&gt;
  
          &lt;xp:eventHandler event="onclick" submit="true"
              refreshMode="partial" refreshId="computedField3"&gt;
              &lt;xp:this.action&gt;&lt;![CDATA[#{javascript: if ( Cdoc.isNewNote() ) { Cdoc.save(); }
  Cdoc.setValue("computedField3",Cdoc.getDocument().getUniversalID());
  getComponent('exampleDialog').show()}]]&gt;&lt;/xp:this.action&gt;
          &lt;/xp:eventHandler&gt;
  </code></pre>
  
  <p></p>
  
  <p>The dialog / <code>Pdoc</code> contains  just 1 button: <code>Save</code> ( because the <code>X</code> button is implicitly added to the dialog )</p>
  
  <pre><code>&lt;xp:button value="Salvare" id="button6" styleClass="lotusFormButton"&gt;
  
  &lt;xp:eventHandler event="onclick"
      submit="true" refreshMode="partial" immediate="false"
      save="false" refreshId="viewPanel1"&gt;
          &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:Pdoc.save();     
  getComponent('exampleDialog').hide();
     }]]&gt;
             &lt;/xp:this.action&gt;
  &lt;/xp:eventHandler&gt;
  </code></pre>
  
  <p></p>
  
  <p>So, it saves the docs. from <code>Pdoc</code> and they are displayed in an embedded view from <code>Cdoc</code>.</p>
  
  <p>The main. doc <code>Cdoc</code> contains also 2 (actions) buttons:</p>
  
  <pre><code>Cancel: redirect to Previous Page.
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Save
  &lt;xp:button value="Salvare" id="buttonSave" styleClass="lotusFormButton" rendered="#{javascript:currentDocument.isEditable()}"&gt;
  
              &lt;xp:eventHandler event="onclick" submit="true"
                  refreshMode="partial" immediate="false" save="true"
                  id="eventHandler1"&gt;
                  &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:if (Cdoc.getItemValueString("txt_UNID")!= "") { 
  
  Cdoc.save(); 
  }
  facesContext.getExternalContext().redirect("http://ourserver.ro/XApp.nsf/view.xsp")
  
  }]]&gt;&lt;/xp:this.action&gt;
              &lt;/xp:eventHandler&gt;
  &lt;/xp:button&gt;
  </code></pre>
  
  <p>The problem is: </p>
  
  <p>Let say I'll create 3 docs. from <code>Pdoc</code> from the dialog, the Cdoc. is already saved ( because the UNID was obtained ). If I save then using <code>Cdoc</code> <code>Save,</code> my main view panel from <code>view.xsp</code> will display:</p>
  
  <ul>
  <li><p>one doc. <code>Cdoc</code> with its 3 <code>Pdoc</code> docs. ( I need just this case to be displayed )</p></li>
  <li><p>another <code>Cdoc</code> ( I guess when I first obtain the UNID and I saved the <code>Cdoc</code> to obtain the UNID, this is the <code>Cdoc</code> in this case.  Btw, if I save again <code>Cdoc</code> using the <code>Save</code> button , will the UNID will change ? ) and one empty ( don't know why ) <code>Pdoc</code> from the dialog.</p></li>
  </ul>
  
  <p>How should my <code>Save</code> button from <code>Cdoc</code> should be like? Should I change also the <code>Save</code> from <code>Pdoc</code> button?</p>
  
  <p>Thanks for your time.</p>