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
new on searchlotus.com: filter the web news (via Ajax, but without XPages...)
Julian Buss, January 3rd, 2010 12:51:59
Tags:  Development 
I decided NOT to use XPages for the searchlotus.com homepage, since I want to be that homepage as fast as possible.
As you might know, searchlotus.com provides specialized Google searches and a tagged and sorted list of "what's new in Google for Lotus stuff".
(That's some kind of experiment, I want to see how useful those web alerts can be.)

As next exercise I wanted to provide one-click filters for the list with re-loading the filtered list via Ajax:

Image:new on searchlotus.com: filter the web news (via Ajax, but without XPages...)

Turns out that this was quite easy actually, thanks to the pre-installed Dojo framework on Domino 8.5.1.
I just added the clickable tags like this:


[a class="alerttag"  href="javascript:" id="alerttagblogs" onclick="changeAlertBox('blogs')"]blogs[/a]

(Note: replace [] with <>, I had to use [] just for this blog software)

with the following javascript function:


function changeAlertBox(channel) {
        if (channel == currentAlertChannel) return;
        dojo.removeClass(dojo.byId("alerttag"+currentAlertChannel), "alerttagactive");
        currentAlertChannel = channel;
        dojo.addClass(dojo.byId("alerttag"+channel), "alerttagactive");
        dojo.xhrGet({url:'/web/searchlotus/searchlotus.nsf/(wAlertsWithChannels)?OpenView&restrictToCategory='+channel+'&start=1&Count=10',
       load: function(data) {
               dojo.byId("alertall").innerHTML = evalLazyHTML(data);
       }
       });
       dojo.xhrGet({url:'/web/searchlotus/searchlotus.nsf/(wAlertsWithChannels)?OpenView&restrictToCategory='+channel+'&start=11&Count=100',
       load: function(data) {                
               if (data.search(/No documents found/) == -1) dojo.byId("alertmoreall").innerHTML = evalLazyHTML(data);
                       else dojo.byId("alertmoreall").innerHTML = "(nothing more)"
       }
       })
}


As you see, I basically do two dojo.xhrGet() calls which load HTML from my alerts-view and puts it into appropriate DIVs .
The evalLazyHTML() function evaluates document.write() calls in the HTML (see last post).

I like the dojo.addClass() and dojo.removeClass() functions which allow me to enable/disable the orange background color on the active tag.

What I learn during my
searchlotus.com tinkering: even classic Domino web coding is much easier with Domino 8.5.1 due to the pre-installed Dojo framework (yes, I know, including Dojo via a content delivery service is just as easy, but I like the idea to have the framework on my own server).
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