Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1416 closed defect (worksforme)

dojo.declare: Subclasses of dojo.collections.Dictionary need a constructor or instantiation fails.

Reported by: dojo.collections.Dictionary Bug Owned by: sjmiles
Priority: high Milestone:
Component: Core Version: 0.3
Keywords: Cc: sjmiles@…
Blocked By: Blocking:

Description

See attached test - self explanatory

Attachments (3)

testMap.html (2.0 KB) - added by guest 13 years ago.
testMap0.html (2.3 KB) - added by guest 13 years ago.
testMap3.html (1.6 KB) - added by guest 13 years ago.

Download all attachments as: .zip

Change History (16)

Changed 13 years ago by guest

Attachment: testMap.html added

Changed 13 years ago by guest

Attachment: testMap0.html added

Changed 13 years ago by guest

Attachment: testMap3.html added

comment:1 Changed 13 years ago by ole_ersoy@…

Priority: normalhighest

Hmmm - This is really strange.

I have other classes that inherit from Dictionary, and they can be created by other dojo objects, unlike what testMap.html suggests.

The difference is the packages that these classes are in are loaded by dojo, on behalf of the other declared classes, instead of the being declared inside a script block like they are in testMap.html.

comment:2 Changed 13 years ago by ole_ersoy@…

BTW - I changed the priority to highest since it's such a fundamental building block for everything else.

Also I think I forgot to hit submit on testMap3.html.

Here I'm just testing adding a object instance directly to a Dictionary instance.

When I get the object back, it's property that was set before it was added, is undefined.

I was going to use the dictionary to cache singleton instances, but I'll have to find a workaround until the Dictionary is fixed...

comment:3 Changed 13 years ago by dylan

Milestone: 0.4
Owner: changed from anonymous to Tom Trenka

comment:4 Changed 13 years ago by Tom Trenka

Component: GeneralCollections
Resolution: invalid
Status: newclosed

This is an invalid bug. There's no problem with the inheritance; the issue here is that you are using [dictionary].entry to try to get at the resultant object, which will return an object of type dojo.collections.DictionaryEntry?, and *not* the original object.

You should change any references to the entry method to "item", like so (from line 59 of your third test):

r = namespacedTagToRendererMap.item(DOJO_WHATEVVA_RENDERER_TAG);

...at which point doing alert(r.rendererTag) will give you what you expect. If you keep the original code, then your alert should look like:

alert(r.value.rendererTag);

comment:5 Changed 13 years ago by ole_ersoy@…

Resolution: invalid
Status: closedreopened

Oooohh - OK - That makes a lot of sense. Thanks.

What about the first test where the initializer is required for instantiation?

This works fine when I require the declared class and dojo loads it, but does not want to work when I declare the class inside the page script block.

I reopened just in case this was overlooked...

comment:6 Changed 13 years ago by Tom Trenka

Component: CollectionsCore
Owner: changed from Tom Trenka to sjmiles
Priority: highestnormal
Status: reopenednew
Summary: Subclasses of dojo.collections.Dictionary need a constructor or instantiation fails.dojo.declare: Subclasses of dojo.collections.Dictionary need a constructor or instantiation fails.

No sure what to tell you, but at that point it's not a Dictionary problem; it's a dojo.declare one. Reassigning to Scott and decreasing the priority.

comment:7 Changed 13 years ago by sjmiles

Cc: sjmiles@… added
Status: newassigned

What about the first test where the initializer is required for instantiation?

I tested testMap.html and couldn't find any problem. Whether NamespacedTagToRendererMap? has an initializer or not made no difference. Did you mean another test?

Fwiw, I ran the test on Windows FF and IE6.

comment:8 Changed 13 years ago by guest

Did you try commenting out the the constructor:

48 initializer: function() 49 { 50 alert('try commenting out this constructor') 51 }

?

I'm running it in FF 1.0.7

comment:9 Changed 13 years ago by ole_ersoy@…

Incidentally,

When getting an item from the dictionary, I was first using the entry function...

This works great when the key is a String and the value is a String.

However, based on what Tom is saying in this ticket, I should get an object of type DictionaryEntry?...

So before I was doing this:

someDictionaryObject.add('aStringKey', 'aStringValue');

then

assertTrue(someDictionaryObject.entry('aStringKey')=='aStringValue');

Should this fail?

comment:10 Changed 13 years ago by Tom Trenka

No, because one of the methods I created on DictionaryEntry? was .toString, which will return the string version of the value property. Using getValue on a DictionaryEntry? will return the actual object stored in the value property.

comment:11 Changed 13 years ago by sjmiles

Did you try commenting out the the constructor:

Yes.

What OS are you using?

comment:12 Changed 13 years ago by sjmiles

Resolution: worksforme
Status: assignedclosed

I can't find any problem here. If the poster wants to reopen with additional information, please do so.

comment:13 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.