Register  Login  
  July 29, 2010  
Search_Blog Minimize
Print  

Blog_Archive Minimize
Print  

Blog    
View_Blog Minimize
Jul 25

Written by: host
Saturday, July 25, 2009 8:02 PM 

Back in the spring of 2004, I was introduced to DotNetNuke via an article  by Jim Duffy  in Code Magizine. I got the magazine from the magazine stand in our office building at noon, and by the time I left for the day I had a site up and running (seems that it was a rather quiet day and no one questioned what I was doing).  Well I was hooked and have been working with DotNetNuke ever since.

One of the first things I did was write a module -- took me several weeks of banging my head as I was completly lost in this new world.  I using DotNetNuke as a learning tool to a) learn VB.Net, b) learn ASP.NET, and c) learn about the web. I have spent the better part of my life developing supervisory process control applications for material handling, so the Web stuff was a complete new territory and DotNetNuke was a nice structured working application that I could extended with my own code -- what could be better!  My first module was T-Minus. 

Well T-Minus is still available today (examples here) and was orignially developed for DNN version 2.  The module includes my very first attempt at javascript - this was one of the many reasons this module took so long to develop.  I slowly got the hang of how to develop modules -- I read every blog or article I could find on DNN module development.  I also had to spend time creating a rather non-trivial javascript to create the display of the amount of time remaining before a given event.  

The javascript had certain requirements:

1. Had to place javascript on page once, but allow multiple modules to exist on a single page.

2. Had to create multiple entries into a object area and have the appropriate value displayed with the correct module.

3. Had to update the display every second as seconds were the smallest unit of time displayed by T-Minus.

4. Had to start the script on page load.

I was able to manage all the requirements and eventually got the module working.  In recent years I updated the module to reflect certain comments I have received over the past 5 year (yikes -- that long?). 

So - this week I get a E-mail from a T-Minus user (many thanks Jerry) that T-Minus will not work with DNNStuff's Aggregator module.  However, the user had passed along DNNStuff's analysis of why the module won't work and how it could be fixed.  WOW!

The root cause of the problem was the javascript that I wrote 5 years ago.  The script used Window.Onload to call my routine to start the display of all the time values.  It works, but is as they say was "bad form" (British acsent needed).  Well in fact it seems that I "hijacked" the Windows.Onload function and did allow any other apps to utilize this function.  DNNStuff recommended that I use DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnLoadEventHandler function to request the start of my display routine.   Today I have corrected the issue and now have a revised version of T-Minus that will "play nice" with the other DNN modules.

While I can't say whether this routine existed back in 2004, I can say now that if I come across a requirement that seems to need coordination amongs the modules on a page, I will look at the DotNetNuke APIs to see if there does exist a function.  So remember children - play nice!.  I will in the future.

Enjoy
Paul.

PS. Many thanks to my fellow Canadian DNN Developer - DNNStuff  - for the helpful push in the right direction.

Tags:

2 comment(s) so far...

Re: Play Nice with others - a Lesson in API calls

Paul, Nice write-up. I like to see others handling "aging" software. I have tons of things just like that (not to mention some IBM BAL370 code!). The funny thing with AddBodyOnLoadEventHandler is that I never saw it mentioned in any DNN docs (surprise?). Unless you used it before, it's hard to stumble upon these things. While I see it the ClientAPI source, it doesn't seem to be used by the core modules (but I may be wrong). Fortunately, I use jQuery so I avoided this issue altogether. Of course, I didn't use DNN in 2004! Anyway, always like to read your blogs. Hope you'll visit ODUG again sometime...

By Mike van der Meulen on   Sunday, July 26, 2009 4:08 PM

Re: Play Nice with others - a Lesson in API calls

Hi Paul,

Glad you got it all fixed up. When I was changing the initialization code for the Aggregator module for version 5.0, I started to use OnLoad for the initial tab selection instead of inlining the javascript and quickly found that there were indeed some modules that didn't play nicely together. Thanks on behalf of myself and other DNN developers in quickly fixing the problem and providing great support to your customers. Well done!

By Richard Edwards on   Tuesday, July 28, 2009 8:28 AM

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 

Blog_List Maximize
Print  

  Home | Blog | Forum | Subscriptions | Free Modules   Page generated in 6.5794608 seconds.
  Copyright 2010 by TressleWorks   Terms Of Use | Privacy Statement