Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6179841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:44:27+00:00 2026-05-24T00:44:27+00:00

I’m a newbie in XUL programming and I learned many things but I’m having

  • 0

I’m a newbie in XUL programming and I learned many things but I’m having a hard time understanding in Firing an observer notification & have the listener on the other XUL window to get the string value from the observer function(The observer passes a string parameter to other XUL window).

This is my tree xil file.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window title="ContactMatrix;"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <script type="application/x-javascript" src="fire.js" />

    <hbox>
<textbox type="search" oncommand="SearchKeyword(this)"/>
    </hbox>

<tree editable="false" id="my-tree" flex="1"   seltype="cell" onclick="onTreeClicked(event)"
datasources="file://C:/mercredi.xml" ref="*" querytype="xml" enableColumnDrag="true" hidecolumnpicker="false"  >
</tree>
</window>

This is my script:

function SearchKeyword(oElem)
{
  var filter = document.getElementById("filter");
  filter.setAttribute("value", oElem.value);
  document.getElementById("my-tree").builder.rebuild();
}


function onTreeClicked(event){
  var tree = document.getElementById("my-tree");
  var tbo = tree.treeBoxObject;

  // get the row, col and child element at the point
  var row = { }, col = { }, child = { };
  tbo.getCellAt(event.clientX, event.clientY, row, col, child);

  var cellText = tree.view.getCellText(row.value, col.value);
  alert(cellText);
observe();
}

XPCOMUtils.defineLazyServiceGetter(this, "obsService", "@mozilla.org/observer-service;1", "nsIObserverService");
  obsService.notifyObservers(null, "xulschoolhello-test-topic", cellText);
let observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(testObserver, "xulschoolhello-test-topic", false);

let testObserver = {
  observe : function(aSubject, aTopic, cellText) {
    if (aTopic == "xulschoolhello-test-topic") {
      window.alert("Data received: " + cellText); //cellText=aData
      var textboxElement = document.getElementByID("ali");
textboxElement.value = cellText; // from the notification
    }
  }
}

var yourAddonObject = {
   obsService:     Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService),

   register: function()
   {

                this.obsService.addObserver(this, "xulschoolhello-test-topic", false);
   }
}

function DisplayContacts()
{
    alert('opening file fire');
var windowObjectReference = window.openDialog("chrome://hello/content/fire.xul","fire");
}

This is my text box XUL file. Where i want to fire the xul tree cell values to the text-box in this file.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window title="Subjects import"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >

    <script type="application/x-javascript" src="fire.js" />

<groupbox>
<caption>Subject(s)</caption>
    <hbox>
    <label  value="Subjects"/>
     <textbox id='ali' value=""/>
     <button label="Contacts" onclick="DisplayContacts();"/>
    </hbox>
</groupbox>
</window>

I have a problem in firing the tree cell values to my another XUL window. From my text-box XUL file I can open my Tree XUL file and when i click on tree cell I can get the values of the tree cell as a alert message. After that my script is not working.

Basically here, when i click on the tree cell, the selected tree cell values should fire to my text-box in the other XUl window.

Some one please help me to fix this problem. Here I have separated scrip file and xul files.
From this website I have taken all the possible scripts.https://developer.mozilla.org/en/XUL_School/Observer_Notifications
Thank you.
Note: I have updated my question in the same post here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:44:29+00:00Added an answer on May 24, 2026 at 12:44 am

    In your posted code you define testObserver after adding the observer, which mean the observer won’t call your observe function but the observe function of an undefined function…
    You should either define it before adding the observer or define the observe function using testObserver.observe = function(){}

    But for a simpler use of observer I would use this file:
    http://code.google.com/p/songbird-telescope/source/browse/trunk/modules/Observers.js?r=2
    This is a wrapper of the nsIObserver.
    You just need to import the file has a module in both file where you want to send and observe a notification:

     Components.utils.import('resource://modules/Observers.js');
    

    You can observe a notification using:

    Observers.add('myTopic', myCallback, myCallbackSubject);
    

    Then, everytime the following line is executed, myCallback is called having parameterForMyCallback as a parameter:

    Observers.notify('myTopic',parameterForMyCallback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to construct a data frame in an Rcpp function, but when I
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.