Michael Vincent van Rantwijk wrote:
> Renato R. (RRaver) wrote:
>
>> 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++) {
And you'll need to switch back to appendItem because insertItemAtIndex
only works if there is already an item at that index.
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners