{"id":666,"date":"2012-04-22T10:07:40","date_gmt":"2012-04-22T08:07:40","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=666"},"modified":"2012-04-22T10:07:40","modified_gmt":"2012-04-22T08:07:40","slug":"xsnippets-fire-querysave-postsave-events","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=666","title":{"rendered":"XSnippets: Fire querySave \/ postSave &#8211; Events"},"content":{"rendered":"<p>The second XSnippet I have added to the <a title=\"openntf.org: XSnippet Contest\" href=\"http:\/\/www.openntf.org\/blogs\/openntf.nsf\/d6plinks\/NHEF-8TF9YU\" target=\"_blank\">XSnippet Contest<\/a> is a help to fire the <em>querySave<\/em>&#8211; and <em>postSave<\/em>-events from SSJS: <a title=\"openntf.org: Save Datasource &amp; Fire querySave\/postSave events\" href=\"http:\/\/openntf.org\/XSnippets.nsf\/snippet.xsp?id=save-datasource-fire-querysavepostsave-events\" target=\"_blank\">Save Datasource &amp; Fire querySave\/postSave events<\/a><\/p>\n<p>If you only do a simple <em>document1.save()<\/em> , the events of a datasource won&#8217;t be executed. To fix this, you have to use the <em>save()<\/em> method of <em>com.ibm.xsp.model.domino.DominoDocumentData<\/em> instead:<\/p>\n<pre>var dsName = \"document1.DATASOURCE\"; \/\/ change this to the name of\r\n                                     \/\/ the datasource you want\r\n                                     \/\/ to save\r\nvar app = facesContext.getApplication();\r\nvar ds = app.getVariableResolver()\r\n           .resolveVariable(facesContext, dsName);\r\nds.save( facesContext, true);<\/pre>\n<p>The variable <em>dsName<\/em> contains the name of the datasource to save, followed by &#8222;<em>.DATASOURCE<\/em>&#8222;. To use it f.e. with the current document, you have to change the variable to &#8222;<em>currentDocument.DATASOURCE<\/em>&#8222;.<\/p>\n<p>The difference here is the type of object that is used: If you save a document datasource, the save method of an object of type NotesXspDocument is called. The com.ibm.xsp.model.domino.DominoDocumentData object has another method for saving. The first object type is like a backend NotesDocument, the second object is like the NotesUIDocument class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The second XSnippet I have added to the XSnippet Contest is a help to fire the querySave&#8211; and postSave-events from SSJS: Save Datasource &amp; Fire querySave\/postSave events If you only do a simple document1.save() , the events of a datasource &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=666\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,76,81,74,40],"tags":[7,5,32,3,92,85],"class_list":["post-666","post","type-post","status-publish","format-standard","hentry","category-javascript","category-ssjs","category-web","category-xpages","category-xsnippet","tag-domino","tag-ssjs","tag-tipp","tag-xpages","tag-xsnippet","tag-xsp"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=666"}],"version-history":[{"count":12,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/666\/revisions\/678"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}