Error in Tightly coupled interaction

gomashan07
User offline. Last seen 9 weeks 4 days ago. Offline
Joined: 01/27/2011
Points: 251

Dear all ,

                  I  am  trying tightly coupled intereaction. I  have done the publisher and  it works fine. But  when  i  do the subscriber i am getting the   Failed to  load app - could not locate the js class .. Sample.TightCouplingSubscriber

i have created the mashups  correctly  for that . Some one help me  with a  solution. I  am trying this  for almost 2 days.

 

I  have enclosed the code of subscriber and the java script of publisher

 

 

 

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Did you use the sample code from the documentation? Or could you post your JavaScript file?

The most common reason for this is a syntax error somewhere in the JavaScript (as I know all *too* well). So one other approach is to use jsLint to check the code. See http://www.jslint.com/ for more information or downloads if you need this.

Sara, technical writer/jackbe

 

gomashan07
User offline. Last seen 9 weeks 4 days ago. Offline
Joined: 01/27/2011
Points: 251

I  have solved the problem. But when  i  run the publisher app seperately it runs  displaying the correct data.And when i run the subscriber seperately this is a static data. And then  what i did  was place  both  the apps in a  mashoboard to see if  it ineracts . But interaction dint happen.When i  click the publisher row no  change happens in the subscriber. And what happens is the  able  in the publisher becomes devoid of data. My doubt is

1. Will  it  be sufficient if i  place the publisher and the subscriber in  the mashoboard.

2.What  will be he  output if i   run  the publisher and subscriber  seperately in the app  editor.

I  am  following the tightly  coupled interaction  given  in he  document. My  code is in  the attachment code .txt . I  have shown code for scripts in publisher and subscriber. Please read  read tht carefully.

smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Sorry I didn't see the attachment in my previous reply. After looking at the code, there are two places in the subscriber App where it differs from the example, but it sounds like you may have found them already. These are:

1. this.rootDiv = jQuery(app.getRootElement);
    should be
    this.rootDiv = jQuery(app.getRootElement());

This was a typo in the original topic that I posted to the Presto Library. Someone kindly pointed it out to me and I have fixed it, but it would be easy to miss. Basically getRootElement() is a method, not a property. Note that this is also a problem in the publisher App.

2.             onFailure: function(e) {
              self.rootDiv.html(e.message);
            }
        });
     }},self);
     
      );
  };
  on your original code is a syntax error (which you have likely found since the class is loading properly). It should be:

            onFailure: function(e) {
              self.rootDiv.html(e.message);
            }
        });
      }, self);
  };
 
};

I believe the problem with your publisher grid data disappearing is caused by a name collision, which again after looking at is probably caused by insufficient information in the documentation. Specifically, your publisher code has this:

Sample.publisher = function( app ) {
  this.app = app;
  var self = this;

  this.onLoad = function(app) {
    this.rootDiv = jQuery(this.app.getRootElement);
    this.myTbl = this.rootDiv.find('.pubTable');
    this.dept = this.rootDiv.find('.options');
    var curPrefix = this.dept.val();
    //hide table initially until job category selected
    if (curPrefix = 'none') {
      self.myTbl.hide();
    } else {
      self.getEmployees();
    }
...

Apparently I had already updated the code from the previous example to change the "myTbl" property to "pubTbl" like this: 

Sample.TightCouplingPublisher = function( app ) {
  this.app = app;
  this.rootDiv = jQuery(app.getRootElement);
  this.pubTbl = this.rootDiv.find('.pubTable');
  var self = this;
 
  this.onLoad = function(app) {
      this.dept = this.rootDiv.find('.deptOptions');
      var curPrefix = this.dept.val();
      //hide table initially until job category selected
      if (curPrefix = 'none') {
        self.pubTbl.hide();
      } else {
        self.getEmployees();
      }
...

Because both you publisher and subscriber Apps are using "myTbl" properties, when the subscriber App clears its grid, it is affecting the grid in the publisher. I will update the topic in the documentation to be clearer about this.

I'm not sure that this solves the problem though. This works for me when I simply add both the Tightly-Coupled publisher and the Tightly-Coupled subscriber App into Mashboard. But your previous comment said something about the subscriber showing static data when you run it outside of Mashboard by itself.

The example subscriber App in this case, should not show *any* data, just the title and static paragraph. Basically it is designed to only show actual employee data in two cases:

1. If added to a workspace App in Mashboard along with the tightly-coupled publisher App.

2. If added to an HTML page as discussed in the topic on tight-coupling (with <script> tags and the appropriate parameters in the URL) when the tightly-coupled publisher App is also loaded in that page.

In answer to your questions: 

1. It should be enough to pull both of these tightly-coupled Apps into Mashboard and save that workspace. Once you do this, the workspace is itself an App and can be used or published just like any other App.

2. If you run publisher in the App Editor, you should be able to select a department and see employee data render in the grid. Clicking on a row of the grid will do nothing that you can see. If you run the subscriber in the App Editor, all you should see is the static heading and paragraph. You cannot display employee name or job history data because there is no way to receive a message from the publisher App -- which is how data is populated in this subscriber App.

Sara, technical writer/jackbe

 

gomashan07
User offline. Last seen 9 weeks 4 days ago. Offline
Joined: 01/27/2011
Points: 251

Hi  sara,

                     Thanks  for the  reply . It  feels  great when  i  see you  have taken  pains  to  reply  to the query . I  have not  yet  solved the problem .I have done  the  subscriber and  publisher and  it  works  fine individually . When i  load them  on  a mash  board it does nt work. The data in the table vanishes when  i select an  option the select button. I have enclosed the coding of  subscriber and and the publisher  in an  attacjment called coding.txt. I   have also  enclosed the images   with the apt name so that  you  can  get the scenario correctly. Please help  me in this regard.