siebelhub JavaScript library – reworked solution

Downloaded siebelhub library published by @lex and had a look at the code. It is fantastic piece of coding with modularized code and well-structured functions. It also helps in understanding basic JavaScript concepts required for Siebel OpenUI development.

The best part was the way to dynamically attach custom functions with PM events such as Field Change or Record Change.  This concept can help us develop truly global functionalities without needing the use of individual PM & PR’s for applets or views.  I used to this to develop a really useful functionality of favorite records. I will share the use case and implementations where this will be useful in future posts but this post is about siebelhub.js. I would recommend everyone to go and download the library and study it as a reference for Siebel OpenUI development.

The only thing that I didn’t like about it is the way the siebelhub object has been made global. Many of you might already know that if in JavaScript we declare a variable without the keyword “var” it becomes part of global namespace and can be accessed by any script that is part of that page.This is very similar to concept of Profile Attributes in Siebel, once you have set a profile attribute you can access its value from anywhere in application. Using this concept @lex has created siebelhub object and attached all the library function to this object. This choice has been made probably because @lex has published this library for educational purpose.

I started looking for other ways by which we can make this library part of Siebel OpenUI framework. I studied few oracle provided js files that have defined similar objects that we use in our custom PM & PR code. My reworked solution is to define siebelhub object as part of “SiebelApp.S_App” Namespace rather than pollute the global namespace and define the library function using prototype object.

The basic structure of library would look like this:

if (typeof(SiebelApp.S_App.siebelHub) === "undefined") {

    SiebelJS.Namespace("SiebelApp.S_App.siebelHub");
    SiebelApp.S_App.siebelHub = (function(){

      function sHub(){
          //you can define private properties here
      };//end of sHub function
      //define all your library functions like this
      sHub.prototype.GoToTheHub = function(){
          window.open("http://www.siebelhub.com");
      };
      sHub.prototype.GoToSiebelUnleashed = function(){
          window.open("http://siebelunleashed.com");
      };
return sHub; //return the object 
}())//end of function as object 
};//end of if 

All the functions of the library would be attached to this function object as shown above. The way to instantiate this library would also change and would be done like this

var sHub = new SiebelApp.S_App.siebelHub(this);
sHub.GetAppletType(appletmap[applet])
sHub.GetFieldValue("Id",pm);

Here is the link to reworked version of SiebelHub Library. I have not included each an every function defined in the original library and it doesn’t have the server side part also. I am not sure if this is best way to do things but I believe that it will certainly make it more compatible with Siebel OpenUI framework. Looking forward to you feeedback/comments and making contributions to make this library better.

2 Responses to siebelhub JavaScript library – reworked solution

Leave a Reply

Contribute