Autor Thema: Save - Button in einem Popup soll ein neues Dok. erstellten und speichern!  (Gelesen 3413 mal)

Offline magic_online

  • Frischling
  • *
  • Beiträge: 10
ich habe folgenden Code, mit dem ich einen Popup in Notes Client öffnen kann:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoForm="true"
   dojoParseOnLoad="true" dojoTheme="true"
   xmlns:xc="http://www.ibm.com/xsp/custom">
   <xp:this.resources>
      <xp:script src="/dojoTesten3.js" clientSide="true"></xp:script>
   </xp:this.resources>
   <xp:this.data>
      <xp:dominoDocument var="document1" formName="profile" computeWithForm="both">
         <xp:this.postSaveDocument>

            <xp:save></xp:save>
         </xp:this.postSaveDocument>
      </xp:dominoDocument>
   </xp:this.data>
   <body class="tundra">
      <xp:form id="form1" dojoType="dijit.form.Form">
   <div dojoType="dijit.Dialog" id="div1" title="Address Dialog"><div dojoType="dijit.layout.ContentPane" title="Address"></div>
         </div>
<!-- CREATE POPUP -->
         <button dojoType="dijit.form.Button" onclick="dlg('add_dlg', true);" id="btnAddressDialog">
            Create Document
         </button>

         <br></br>
   <xp:panel id="panel1">
      <xp:br></xp:br>      
   
         <div dojoType="dijit.Dialog" id="add_dlg" title="Neue Daten">

            <div dojoType="dijit.layout.ContentPane" title="neueDaten">
               <div id="allData">
<!-- INPUT inputText1 -->
                  <input id="inputText1" value="" dojoType="dijit.form.ValidationTextBox">
                  </input>
<!-- INPUT inputText2 -->                  
         <xp:inputText id="inputText2" dojoType="dijit.form.ValidationTextBox" value="#{document1.FirstName}">
         </xp:inputText>
                  
<!-- TRANSFER -->
                  <button dojoType="dijit.form.Button" id="button2" onclick="doSave('allData', 'inputText1');">
                     Transfer
                  </button>
               </div>
<!-- SAVE1 -->
               <xp:button value="Save1" id="button1" dojoType="dijit.form.Button" save="true">                  
                  <xp:eventHandler event="onclick" immediate="false" save="true" submit="false">
                                       
                     <xp:this.script>
                        <xp:executeClientScript>
                           <xp:this.script><![CDATA[
var lastName = dojo.byId("#{id:inputText1}");
alert(lastName.value);
var lastNameNew = dojo.byId("#{id:inputText3}");
lastNameNew.value = lastName.value;

]]></xp:this.script>
                        </xp:executeClientScript>
                     </xp:this.script>
                     <xp:this.action>
                        <![CDATA[#{javascript:getComponent("inputText3").setValue(getComponent("inputText2").getValue());
var doc = database.createDocument();
doc.appendItemValue("LastName","testedich");
doc.save();
/*
var newDoc = database.createDocument();
newDoc.copyAllItems(currentDocument);
*/

//document1.setValue("Email",getComponent("inputText1").getValue());
//document1.save();}]]>
                     </xp:this.action></xp:eventHandler>
               </xp:button>
<!-- SAVE2 -->
               <button dojoType="dijit.form.Button" id="buttonSave">Save2<xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true">
                  </xp:eventHandler>
               </button>
<!-- CANCEL -->
               <button dojoType="dijit.form.Button" id="buttonCancel" onclick="dlg('add_dlg', false);">
                  Cancel
               </button>
               <xp:br></xp:br></div></div><xp:br></xp:br>
               </xp:panel>
   <xp:br></xp:br>

   

   
   
<!-- INPUT inputText2 -->
         <xp:inputText id="inputText3"
            value="#{document1.Email}">
         </xp:inputText>
         <xp:br></xp:br>aacw<xp:br></xp:br><xp:br></xp:br>

<!-- SAVE3 -->
         <xp:button value="save3" id="button3">
            <xp:eventHandler event="onclick" submit="true"
               refreshMode="complete" immediate="false" save="true">
               
               <xp:this.script>
                  <xp:executeClientScript>
                     <xp:this.script><![CDATA[var date = dojo.byId("#{id:inputText3}");
alert(date.value);]]></xp:this.script>
                  </xp:executeClientScript>
               </xp:this.script>
               <xp:this.action>
                  <xp:saveDocument></xp:saveDocument>
               </xp:this.action></xp:eventHandler>
         </xp:button>
      
   </xp:form>
   </body>
</xp:view>

und meine dojoTesten3.js Datei:

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.Form");

function dlg(dialogId, flag) {
       var myDialog = dijit.byId(dialogId);
       if (flag){
          myDialog.show();
       }else {
          dojo.hitch(myDialog.hide());
       }
    }

var createDialog = function(){
// dijit.byId('add_dlg')
   var dlg = dijit.byId("add_dlg");
   dlg.show();
   
   var btnClose = new dijit.form.Button({
      label:'Close',
      onClick: function(){
         dojo.hitch(this, dlh.hide());
      }
   });
   
};

function doSave(objDiv, objInput){
alert(3);
//var myDiv = document.getElementById(objDiv);
//var test = myDiv.innerHTML;

var myData1 = dijit.byId(objInput);
alert("-->" + mydata1.value);

   
}

dojo.ready(function() {
    //createDialog();
});


Ich habe einfach den ganzen Code hier kopiert   ???! Wenn Sie eine neue xPages erstellen und die js Datei einbinden, und wenn Sie auf Create Document klicken, sollte man einen Popup öffnen.
Das Problem ist, wenn ich auf die Save1 (in Popup) klicke, möchte ich, dass ein Dokument in der DB gespeichert wird!
Nun, es wird nichts gespeichert!
Wenn ich  submit="true" setze (unter save1), dann passiert auch nichts...

Unter SSJS habe ich noch folgende eingetragen:


var doc = database.createDocument();
// "LastName" ist ein Feld in meiner Maske "profile"
doc.appendItemValue("LastName","testedich");
doc.save();

Was mache ich falsch, dass ich kein Dokument erstellen und speichern kann???

Ich bin für jeden Hinweis sehr dankbar!  :'(


Offline Sven Hasselbach

  • Senior Mitglied
  • ****
  • Beiträge: 316
  • Geschlecht: Männlich
    • blog@hasselba.ch
Meines Wissens hat das XSP-Object Probleme mit Dojo-Dialogen. Das könnte einer der Gründe sein, warum kein serverseitiges Event ausgeführt wird (oder kannst Du was in die Konsole printen?)

Schau mal hier:
http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_Dojo#Use+a+panel+as+dijit+Dialog
http://openntf.org/XSnippets.nsf/snippet.xsp?id=xpages-compatible-dojo-dijit-dialog

Offline magic_online

  • Frischling
  • *
  • Beiträge: 10
GENIAL!!!

Also, ich habe folgende ergänzt (mit blau!!! Unrsprünglich sah wie oben aus!):

Zitat
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" dojoForm="true"
   dojoParseOnLoad="true" dojoTheme="true"
   xmlns:xc="http://www.ibm.com/xsp/custom">
   <xp:this.resources>
      <xp:script src="/dojoTesten3.js" clientSide="true"></xp:script>
<xp:script src="/comZetaOneDialog.js" clientSide="true"></xp:script>
   </xp:this.resources>
   <xp:this.data>
      <xp:dominoDocument var="document1" formName="profile"
         computeWithForm="onsave">
         <xp:this.postSaveDocument>

            <xp:save></xp:save>
         </xp:this.postSaveDocument>
      </xp:dominoDocument>
   </xp:this.data>
   <body class="tundra">
      <xp:form id="form1" >

<!-- CREATE DOCUMENT -->
         <button dojoType="dijit.form.Button" onclick="dlg('add_dlg', true);" id="btnAddressDialog">
            Create Document
         </button>

         <br></br>
   <xp:panel id="panel1">
      <xp:br></xp:br>
   
      
   
         <div dojoType="com.ZetaOne.widget.Dialog" id="add_dlg" title="Address Dialog">

            <div dojoType="dijit.layout.ContentPane" title="Address">
               <div id="allData">
<!-- INPUT inputText1 -->
                  <input id="inputText1" value="" dojoType="dijit.form.ValidationTextBox">
                  </input>
<!-- INPUT inputText2 -->                  
         <xp:inputText id="inputText2" dojoType="dijit.form.ValidationTextBox" value="#{document1.FirstName}">
         </xp:inputText>
                  
<!-- TRANSFER -->
                  <button dojoType="dijit.form.Button" id="button2" onclick="doSave('allData', 'inputText1');">
                     Transfer
                  </button>
               </div>
<!-- SAVE1 -->
                  <xp:button value="Save1" id="button1" dojoType="dijit.form.Button">                  
                  <xp:eventHandler event="onclick" immediate="false" save="true" submit="true">         
   
                     
                     <xp:this.script>
                        <xp:executeClientScript>
                           <xp:this.script><![CDATA[
var lastName = dojo.byId("#{id:inputText1}");
alert(lastName.value);
var lastNameNew = dojo.byId("#{id:inputText3}");
lastNameNew.value = lastName.value;

]]></xp:this.script>
                        </xp:executeClientScript>
                     </xp:this.script>
                     <xp:this.action>
                        <![CDATA[#{javascript:getComponent("inputText3").setValue(getComponent("inputText2").getValue());
var doc = database.createDocument();
doc.appendItemValue("LastName","testedich");
doc.save();
/*
var newDoc = database.createDocument();
newDoc.copyAllItems(currentDocument);
*/

//document1.setValue("Email",getComponent("inputText1").getValue());
//document1.save();}]]>
                     </xp:this.action>
</xp:eventHandler>
               </xp:button>
<!-- SAVE2 -->
               <button dojoType="dijit.form.Button" id="buttonSave">Save2<xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true">
                  </xp:eventHandler>
               </button>
<!-- CANCEL -->
               <button dojoType="dijit.form.Button" id="buttonCancel" onclick="dlg('add_dlg', false);">
                  Cancel
               </button>
               <xp:br></xp:br></div></div><xp:br></xp:br>
               </xp:panel>
   <xp:br></xp:br>   
   
<!-- INPUT inputText2 -->
         <xp:inputText id="inputText3"
            value="#{document1.Email}">
         </xp:inputText>
         <xp:br></xp:br>aacw<xp:br></xp:br><xp:br></xp:br>

<!-- SAVE3 -->
         <xp:button value="save3" id="button3">
            <xp:eventHandler event="onclick" submit="true"
               refreshMode="complete" immediate="false" save="true">
               
               <xp:this.script>
                  <xp:executeClientScript>
                     <xp:this.script><![CDATA[var date = dojo.byId("#{id:inputText3}");
alert(date.value);]]></xp:this.script>
                  </xp:executeClientScript>
               </xp:this.script>
               <xp:this.action>
                  <xp:saveDocument></xp:saveDocument>
               </xp:this.action></xp:eventHandler>
         </xp:button>
      
   </xp:form>
   </body>
</xp:view>

und natürlich, die neue comZetaOneDialog.js Datei:

Zitat
dojo.provide('com.ZetaOne.widget.Dialog');
dojo.require('dijit.Dialog');
 
(function(){
    dojo.declare("com.ZetaOne.widget.Dialog", dijit.Dialog, {
        postCreate: function(){
          this.inherited(arguments);
          dojo.query('form', dojo.body())[0].appendChild(this.domNode);
        },
        _setup: function() {
          this.inherited(arguments);
          if (this.domNode.parentNode.nodeName.toLowerCase() == 'body')
            dojo.query('form', dojo.body())[0].appendChild(this.domNode);     
        }     
    })
}());

Und, FUNKTIONIERT!!!

Wenn Sie die xPages mit dem Code erstellen, werden 2 Dokumente erzeugt: das eine durch submit=true, das andere durch SSJS:

Zitat
<xp:this.action>
                        <![CDATA[#{javascript:getComponent("inputText3").setValue(getComponent("inputText2").getValue());
var doc = database.createDocument();
doc.appendItemValue("LastName","testedich");
doc.save();
/*
var newDoc = database.createDocument();
newDoc.copyAllItems(currentDocument);
*/

//document1.setValue("Email",getComponent("inputText1").getValue());
//document1.save();}]]>
                     </xp:this.action>

Nun, jetzt habe ich ein schönes Wochenende  :knuddel:
DANKE!

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz