Sie können mich buchen für:
Individuelle Schulungen für XPages, JavaScript und Appcelerator Titanium Software-Entwicklung für IBM XPages, Appcelerator Titanium (Mobile Apps iPhone, iPad, Android, Blackberry 10), Mobile Web und IBM Notes
How to work with two Lotus Notes databases in one mobile iOS App with Domino To Go
Julian Buss, June 1st, 2012 14:32:48
Tags:  dominotogo  Lotus Domino 
Today I needed to prepare myself for a presention of Domino To Go. The client asked me if it's possible to work with two NSF databases in one mobile App. Instantly I said "yes!", but nevertheless, I wanted to prove it. So I quickly build an example as follows:

1.) I copied the small demo App coming in the Domino To Go package to a new project. This demo App already synchronizes the content of the "people" view of a standard Domino address book to the iPhone or iPad and displays it on the device.

2.) I renamed the file "navigation.js" to "navigation_db1.js" and duplicated that to "navigation_db2.js". The navigation.js contains code to build the view in the mobile App. I changed some variable names in both files to reflect that one is for "db1" and the other is for "db2".

3.) In "app.js" I added one more tab to the tabgroup, so that one tab opens the view of "navigation_db1.js" and the other the view of "navigation_db2.js".

4.) In "navigation_db2.js" I changed the creation of the NotesDatabase object so that is uses a NotesDatabase with the name "contacts2" instead of "contacts".

5.) In "sync.js" I added code to instanciate a second NotesDatabase object with the name "contacts2" and a different URL, and to update the people view from that seconds database.
Here is the full code of sync.js. You can see that in sync(), the view of the first database is updated (synchronized). Then sync_2 is called (via callback), which updates the view of the second database.


var sync_viewUpdateDone = function(success, e) {
       try {
               if (!success) {
                       YN.log("view update failed: "+e);
               } else {
                       App.window_navigation_db2.update();
               }
       } catch (e) {
               YN.exception("sync_viewUpdateDone", e);
       }
}

var sync_2 = function(sucess, e) {
       // update navigation window for db1
       App.window_navigation_db1.update();                        
       // get db2
       var db = new NotesDatabase("http://youatnotes.com/youatnotes/development/dominotogo/dtg-demo_contacts2.nsf", "contacts2");
       var view = db.getView("People");
       // and update it's view, run sync_viewUpdate when done
       view.update(sync_viewUpdateDone, false, "Cannot read view 'People': %s");
}

function sync() {
       try {
               // get the content of the people view of first database
               var db = new NotesDatabase("http://youatnotes.com/youatnotes/development/dominotogo/dtg-demo_contacts.nsf", "contacts");
               var view = db.getView("People");
               // update the view from Domino, run sync_2 when done
               view.update(sync_2, false, "Cannot read view 'People': %s");
       } catch (e) {
               YN.exception("sync", e);
       }
}


And basically that was it. I needed to change some variable names here and there, but in general, the changes above did the job. It was a work of minutes, super easy.

This example shows how super flexible Domino To Go is. You can work with multiple Notes database, you could even mix Notes data with data from other data sources. With Domino To Go, you have the power to do it the way you like.

Here are two screenshots: you can see two views in the App, each view displays contacts of another NSF database.

Image:How to work with two Lotus Notes databases in one mobile iOS App with Domino To Go Image:How to work with two Lotus Notes databases in one mobile iOS App with Domino To Go
Comments (0) | Permanent Link

Comments:
No Comments Found
Add a comment
Subject:
   
Name:
Mail:
Web:
 
Comment:  (No HTML - URLs with leading http://)
 
remember me?   
You can hire me.
See my Linkedin profile for details.

Thanks for reading and have a nice time here!

Please note my Apps for iPhone and iPad: NotesBook: takes your Lotus Notes Notebook (Journal) to your iPhone and iPad xpageswiki.com: huge XPages Tips & Tricks collection for iPhone and iPad