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
Secret XPages app sneek preview 2: "follow me" logic and how it works
Julian Buss, June 24th, 2009
Tags:  XPages 
Yesterday I told you first facts about my new XPages application named "YouAtNotes CSC".

As promised, here is the next piece of the puzzle :-)

In YouAtNotes CSC I have some kind of content which a user can follow. There is heart icon, the user clicks on it and gets something like this:

Image:Secret XPages app sneek preview 2: "follow me" logic and how it works

After clicking OK, there is a nice animation and then he follows that content. Clicking again on the heart disables the follow again.
Click here to see a short movie about that.

To follow a content means that the user gets notified via mail when there is a change at that content. Something like subscribing to a thread in a forum.

How is that implemented?


After clicking on the gray heart an agent is executed via a Dojo xhrGet call (that means, via Ajax):


dojo.xhrGet({
      url : '(follow)?Open&unid='+unid+'&a='+a+"&u="+escape(user)+"&l="+lang,
      load : followCallback1,
      error : function(response, ioArgs) {
              console.log("error", response, ioArgs);
      }        
});


The "(follow)" agent is a LotusScript agent which:
  • gets the parameters out of the URL via session.documentContext.query_string(0)
  • gets the content document form by UNID (taken from the "u" URL parameter)
  • saves the name of the user into a field in the document (a richtext field so that we don't come to the 64k limit of plain text fields).
  • finally simply prints out "1" if everything worked fine

The Dojo xhrGet call gets that "1" returned and calls the "followCallback1" JavaScript method then. This method checks if the return value is "1" and if so, makes the nice animation on the heart icon.

So, after the user clicked and the agent ran, the content document has the name of the user in a list in a field. In the future, when something is added to the doc, another logic checks that field and sends a mail to all users listened in that field.

Clicking again on the heart to cancel the follow uses basically the same logic.

What you know now


is that YouAtNotes CSC is a web application which contains some kind of content. Users can follow a specific content and get updated when there is a change.

What you don't know yet


There are many, many other features left I will talk about in the next days so you can solve the puzzle :-)
Any guesses yet what CSC is about?





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