Re: Help Posting form with file input using elemental

2015-04-21 Thread Ümit Seren


Jens approach should work.
Another approach, for example if you are missing some functions like the 
append(String 
name, Blob file, String filename) on elementals interfaces, is this:

public static class ExtJsFormData extends JsFormData {

protected ExtJsFormData() {
}

public final native static ExtJsFormData newExtJsForm() /*-{
return new $wnd.FormData();
}-*/;

public final native void append(String name, Blob file, String 
filename) /*-{
this.append(name, file, filename);
}-*/;
}

On Tuesday, April 21, 2015 at 1:44:47 AM UTC+2, Wayne Rasmuss wrote:

I've been working on file uploading to AppEngine using the blob store. I 
> would like to do so in the background using elemental (no suggestions for 
> 3rd party libraries please.) I think I have it mostly figured out but I 
> can't figure out the code to get the form data from the form element.
>
> The java script should look like this:
> var formElement = 
> document.getElementById("formElementID");
> var request = new XMLHttpRequest();
> request.open("POST", "urltopostto");
> request.send(new FormData(formElement));
>
>
> Here's my java code with elemental. The last line has the part I can't 
> figure out.
>
> FormElement formElement = (FormElement) 
> Browser.getDocument().getElementById("uploadForm");
> XMLHttpRequest request = 
> Browser.getWindow().newXMLHttpRequest();
>
> request.open("POST", uploadUrl);
> request.send(!!!NEED FORM DATA FROM MY FORM 
> ELEMENT HERE);
>
> General guidance on how to map JS to Elemental code would be great.
>
>  
>
​

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: Help Posting form with file input using elemental

2015-04-20 Thread Wayne Rasmuss
I'm sure Jens' answer would also work, but I had already tried this 
approach (very similar) and it seems to work.

public static native FormData getFormData() /*-{
var formElement = $doc.getElementById("uploadForm");
return new FormData(formElement);
}-*/;


On Monday, April 20, 2015 at 7:02:59 PM UTC-5, Jens wrote:
>
> Seems like there is no obvious Elemental API to create a FormData 
> instance. Maybe JSNI works:
>
> private native FormData createFormData(FormElement elem) /*-{
>   return new FormData(elem);
> }-*/;
>
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: Help Posting form with file input using elemental

2015-04-20 Thread Jens
Seems like there is no obvious Elemental API to create a FormData instance. 
Maybe JSNI works:

private native FormData createFormData(FormElement elem) /*-{
  return new FormData(elem);
}-*/;


-- J.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Help Posting form with file input using elemental

2015-04-20 Thread Wayne Rasmuss
I've been working on file uploading to AppEngine using the blob store. I 
would like to do so in the background using elemental (no suggestions for 
3rd party libraries please.) I think I have it mostly figured out but I 
can't figure out the code to get the form data from the form element.

The java script should look like this:
var formElement = 
document.getElementById("formElementID");
var request = new XMLHttpRequest();
request.open("POST", "urltopostto");
request.send(new FormData(formElement));


Here's my java code with elemental. The last line has the part I can't 
figure out.

FormElement formElement = (FormElement) 
Browser.getDocument().getElementById("uploadForm");
XMLHttpRequest request = 
Browser.getWindow().newXMLHttpRequest();

request.open("POST", uploadUrl);
request.send(!!!NEED FORM DATA FROM MY FORM 
ELEMENT HERE);

General guidance on how to map JS to Elemental code would be great.

 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.