Places:Transactions: Difference between revisions

Jump to navigation Jump to search
No edit summary
 
Line 39: Line 39:
<code>function PlacesEditBookmarkKeywordTransaction(uri, newKeyword);</code>
<code>function PlacesEditBookmarkKeywordTransaction(uri, newKeyword);</code>


= Grouping Transactions =  
= Grouping Transactions =
 
Several transactions can be aggregated together into a single atomic unit of work using <code>PlacesAggregateTransaction</code>. For example, consider creating and naming a new Bookmark:
 
<pre>
var ios =
    Cc["@mozilla.org/network/io-service"].
    getService(Ci.nsIIOService);
var uri = ios.newURI("http://www.mozilla.org/", null, null);
var bms =
    Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    getService(Ci.nsINavBookmarksService);
var createTxn = new PlacesCreateItemTransaction(uri, bms.toolbarRoot, -1);
var nameTxn = new PlacesEditItemTitleTransaction(uri, "Mozilla.org");
 
var aggTxn = new PlacesAggregateTransaction("Create Bookmark",
                                            [createTxn, nameTxn]);
PlacesController.tm.doTransaction(aggTxn);
</pre>
 
The aggregator does/undoes/redoes each of the transactions in the set provided.


= Creating Folders =  
= Creating Folders =  


= Removing Folders =
= Removing Folders =
525

edits

Navigation menu