Opened 12 years ago

Closed 12 years ago

#10332 closed defect (wontfix)

FileUploader as part of another widget

Reported by: ben hockey Owned by: Mike Wilcox
Priority: high Milestone: future
Component: DojoX Form Version: 1.3.2
Keywords: Cc: Josh Trutwin
Blocked By: Blocking:


using fileuploader as part of another widget can be problematic. most times, you would create any 'subwidgets' in postCreate. however, fileuploader seems to need to be created in startup.

this bug was opened in response to

all of the dijit widgets (at least all that I've used) do not have a dependency on the srcNodeRef being in the document at the time they are created. FileUploader?, however, depends on the widget being in the document (as opposed to just having a node outside of the document) because when the uplaoder is created, it tries to inspect the style properties (size, position, etc.) of the srcNodeRef which have a dependency on actually being in the document and having css applied, etc. because of this, the only safe time to create a FileUploader? based on a node in your main widget's template is in startup.

even though the nodes of the template are guaranteed to exist at postCreate, it is still not guaranteed that your widget is in the document until startup. consider the following:

var w = new SomeWidgetWithUploader(props).placeAt(parent);

the postCreate of someWidgetWithUploader will be called before the .placeAt(parent) - so if you tried to create the uploader in the postCreate of SomeWidgetWithUploader? then it would fail. however, if you created the widget like so

var w = new SomeWidgetWithUploader(props, node);

iirc, the uploader will work as long as the node is already in the document and it will fail if your node was not yet in the document.

startup seems to be the best place to create the uploader because if you use placeAt to put your main widget into the document, then if parent is a node, you should explicitly call startup on your widget after you place it in the document, or if parent is some kind of container widget then the container will call startup on your widget at some point after your widget is in the document.

despite the claims that you can 'Just create your uploader like any other widget' ( it's not quite true, but in fairness, the claim is true based on widgets pre dojo ~1.2 (before placeAt was introduced and widgets had to have a srcNodeRef).

I believe that a step in the right direction towards making this claim somewhat 'truer' would be for the FileUploader? to attempt to move some (or all) of it's postCreate into startup. however, this has the downside that now you have to call startup explicitly for the FileUploader? to work and I'd probably not like that either ;)

another exception to this claim is that you cannot create a fileuploader like so:

var f = new dojox.form.FileUploader(props).placeAt(anything);

because the uploader's postCreate will be called before the placeAt and so srcNodeRef will be null in postCreate.

i don't think this is a case where you should try to cater to me (or any other particular person) but the docs should at least note these exceptions to the claim.

my ideal case would be if the behavior would match what the docs claim right now but maybe an update to the docs is all that is needed to make it 'right'.

Change History (5)

comment:1 Changed 12 years ago by ben hockey

Component: GeneralDojoX Form
Owner: changed from anonymous to dante
Version: 1.4.0b1.3.2

forgot to note the version and component

comment:2 Changed 12 years ago by Josh Trutwin

please add trutwijd to CC list - thx

comment:3 Changed 12 years ago by dante

Cc: Josh Trutwin added
Owner: changed from dante to Mike Wilcox

comment:4 Changed 12 years ago by dante

Milestone: tbdfuture

comment:5 Changed 12 years ago by Mike Wilcox

Resolution: wontfix
Status: newclosed

Docs have been updated. As you suspected, the functionality would be very difficult to achieve. The Flash plugin is hair-pullingly difficult to work with.

Note: See TracTickets for help on using tickets.