How to send Post-Data to Window.open?

5,054 views
Skip to first unread message

walsi

unread,
Aug 22, 2008, 9:11:04 AM8/22/08
to Google Web Toolkit
Hi all,

I try to open a URL with

Window.open(url, "_blank", "");

where GET-Data is in the url-variable. As the url-String is too long
(and because I want to hide the information) I want to send my data
via POST. Is this possible? If not, what other possibilities do I
have?

I need to open a new window with a given url where I sent POST-data to
that url. (i.e., it's a php-file generating a PDF out of the data I
sent to it).

Thanks a lot for your help,

Stefan

Agnes

unread,
Aug 22, 2008, 10:00:48 AM8/22/08
to Google Web Toolkit
On that note,
I am not sure how window.open works,
what does the parameter features. The arguments are specified here
link does not work. I am looking for help on this as well, where I
have an uploadfile widget where the data would be sent to a server,
google maps api, and then it ouputs to another url page, I think that
what window.open does, right, and ouput the data there. I am trying to
learn how to do that as well. Any help about this would be
appreciated.

This was taken from:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/user/client/Window.html#open(java.lang.String,%20java.lang.String,%20java.lang.String)


open
public static void open(java.lang.String url,
java.lang.String name,
java.lang.String features)Opens a new browser
window. The "name" and "features" arguments are specified here.

Parameters:
url - the URL that the new window will display
name - the name of the window (e.g. "_blank")
features - the features to be enabled/disabled on this window

Thomas Broyer

unread,
Aug 22, 2008, 10:13:48 AM8/22/08
to Google Web Toolkit

On 22 août, 15:11, walsi <stefan.walk...@gmail.com> wrote:
> Hi all,
>
> I try to open a URL with
>
> Window.open(url, "_blank", "");
>
> where GET-Data is in the url-variable. As the url-String is too long
> (and because I want to hide the information) I want to send my data
> via POST.

(are we still in the 20th century?! I thought people here in the 21st
c. knew about REST principles and how they apply to HTTP: GET is
idempotent while POST isn't; it's not about "I want to use POST vs.
GET" but "I *need* to use POST vs. GET")

> Is this possible?

Yes and no...
Give a name to your window and use that name in the target of your
form (this means you have to use a form).
...or if you don't want to play with the window "features" (size,
resizeability, position, scrolling, toolbars and menubar, etc.), just
use _blank or another target for your form (and you'll have to use a
form).

> If not, what other possibilities do I have?

You can send a POST in response to which the server generates a
temporary file and sends back the URL to that file, and then use
Window.open with that URL to open the generated file in a new window.
This has the advantage to work with a RequestBuilder to send the
initial POST.

> I need to open a new window with a given url where I sent POST-data to
> that url. (i.e., it's a php-file generating a PDF out of the data I
> sent to it).

Do several requests with the same sent "data" should result in the
same PDF being generated? If so, then you need GET (eventually, you
could use the POST+tempfile+GET approach, where the server optimizes
the POST handling using memoization [1]).
If the same input data results in different files over time, you might
have caching issues however, so using POST might proves useful, and
memoization would then help optimizing (adding to the equation the
time when the data last changed).
...but this is unrelated to GWT...

[1] e.g. generate a hash of the input data, if the corresponding
tempfile exists, you don't need to regenerate it, otherwise, generate
it with the hash as the filename.

Agnes

unread,
Aug 22, 2008, 11:14:19 AM8/22/08
to Google Web Toolkit
Hi Thomas,
I am a beginner, I got a new browser with no scrolling, you said you
can add scrolling into open window, I typed
the following:
Window.open("http://google.com", "_blank", "_scrolling");
for example and I got it to work but no scrolling, the link explaining
what features does, isn't working which is why I ask. Can you explain
more what Post and Get do, I am learning, and this example above
appears simple.Suppose I create a simple upload widget, where it
uploads a file, I got a working code for that. And it opens a browser
showing the output of the text file looking like this:
Your output is complete. Click on the link below to open the output
file.

220901480.txt (100 KB, 2010 observations 4 variables)
How would want do that? There are too many libraries in gwt, but it is
organize, but I am a beginner and in the process of learning.
Best Regards,
Agnes
Reply all
Reply to author
Forward
0 new messages