-
22 Jan 2013 12:19 PM #11
The use case for this particular situation is to open a window that harbors a FormPanel with two fields (one being the FileUploadField.) This window is modal, and does not close until the onSubmit event finishes processing (which should be after the submit completes, if I understand the API correctly.)
That's the general gist/use-case. To my understanding, the FormPanel should always be attached in this scenario, right?Code:Window w = new Window(); FormPanel fp = new FormPanel(); VerticalLayoutContainer vlc = new VerticalLayoutContainer(); w.setWidget(fp); fp.setWidget(vlc); ... // other widget setup -- FileUploadField and TextArea into vlc, etc fp.setMethod(FormPanel.Method.POST); fp.setEncoding(FormPanel.Encoding.MULTIPART); fp.setAction(GWT.getHostPageBaseURL() + "datatransfer"); fp.addSubmitHandler(new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { // processing Utils.getSvc().doThing(selected, new AsyncCallback<AdViewGwt>() { @Override public void onFailure(Throwable caught) { Utils.reportError(caught, "Unable to attach file!"); } @Override public void onSuccess(BaseModel result) { selected.set("addFile", null); w.hide(); } }); } }); note.addButton(new TextButton("Save", new SelectHandler() { @Override public void onSelect(SelectEvent ce) { fp.submit(); } }));
-
22 Jan 2013 1:03 PM #12
Agreed - that looks reasonable. Without being able to run it and reproduce it, I can't say much more without lots of guessing.
I brought up attach/detach because you said that the synthesizedFrame was null. This is set to a non-null value in com.sencha.gxt.widget.core.client.form.FormPanel.onAttach(), which should be called when the widget is attached to the dom (when w.show() gets called in the above code). If onAttach isn't getting called, you'll have all kinds of other issues as well, like the fact that events won't be firing in fields/buttons, etc, so that almost certainly is working. This field then is only nulled out in onDetach().
If it is null, the FormPanel isn't attached.
-
22 Jan 2013 1:12 PM #13
In my current debugging session, I am clicking a button that calls form.submit();
It is hitting FormPanel line 399 (first line of onDetach()) and THEN going to line 370 (submit()).
-
22 Jan 2013 1:15 PM #14
See the (hopefully attached) image for Netbeans' representation of the callstack.
-
22 Jan 2013 1:18 PM #15
From this, it appears that the onSubmit/SubmitHandler are called when FormPanel.submit() is fired, not when the submission is complete. This would explain a lot. Is there an alternative way to listen for when the submission is completed?
EDIT: SubmitComplete handler. I'm dumb.
Last edited by scaswell1; 22 Jan 2013 at 1:19 PM. Reason: I'm dumb.
-
22 Jan 2013 1:40 PM #16
Sorry for the confusion - I should have caught that as well (since you are hiding the window in your submit event handler).
Is there still an issue, or can I close this bug?
-
22 Jan 2013 1:43 PM #17
You can close it - that was definitely the problem. Really sorry for time drain!
-
22 Jan 2013 2:01 PM #18
No problem - In my brief look to see if I should add additional documentation for this point, I found this:
Clearly we should mention this in at least one other place - I'll make a note of this on the event itself, and perhaps in the FormPanel too.Code:/** * Fired when the form is submitted. * * <p> * The FormPanel must <em>not</em> be detached (i.e. removed from its parent * or otherwise disconnected from a {@link RootPanel}) until the submission * is complete. Otherwise, notification of submission will fail. * </p> * * @param event the event */ void onSubmit(SubmitEvent event);
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote