[Project_owners] insertItemAt uncaught exception

Michael Vincent van Rantwijk mv_van_rantwijk at yahoo.com
Sat Apr 21 22:24:49 PDT 2007

Renato R. (RRaver) wrote:
> Hi guys,
> I'm trying to populate a listbox with some stored preferences but it 
> doesn't work if I use inserItemAt only if I use appendItem, but 
> appendItem is giving me a unordered list that changes its order 
> everytime it is populated, so I decided to use insertItemAt...
> The code I am using is something like this...
>            var signatures = 
> prefService.getBranch("").getChildList("myExt.signatures", {});
>            for (var i in signatures) {
>                signaturesList.insertItemAt(i, 
> myPref.getCharPref(signatures[i]) );
>            }
> and the error is
> Error: uncaught exception: [Exception... "Component returned failure 
> code: 0x80004005 (NS_ERROR_FAILURE) [nsIListBoxObject.getItemAtIndex]"  
> nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: 
> chrome://global/content/bindings/listbox.xml :: getItemAtIndex :: line 
> 481"  data: no]

getItemAtIndex is called from method inserItemAt in listbox.xml and your 
problem here is, most likely, an index (i) problem.  Add a dump("\ni:" + 
i); to check the index, and be surprised, or change this line:

-for (var i in signatures) {
+for (var i=0; i < signatures.length; i++) {


More information about the Project_owners mailing list