Easiest way to open a new window with some text in it?

23 views
Skip to first unread message

darkflame

unread,
Nov 20, 2008, 4:11:29 PM11/20/08
to Google Web Toolkit
Any ideas?
The text is dynamic, so I thought at first I'd just use;

Window.open("scripts/display.php"+"?text="+messageslist.getText(),
"_blank", null);

Where display.php simply gets the text variable in the url and echo's
it back.

However, this has a very short limit on the text that can be
displayed.
Is it possible to do a simerla function with RequestBuilder? So Post
can be used correctly?
I have no idea if its possible to use RequestBuilder to open a php in
a new window, so if it isn't I would welcome workarounds if its not.

Cheers,




Danny Schimke

unread,
Nov 21, 2008, 2:13:35 AM11/21/08
to Google-We...@googlegroups.com
You could try to use JSNI to open a new window as you've already done:

It should look something like this:

native JavaScriptObject openWindow(String param) /*-{
        $wnd.open('scripts/display.php' + '?text=' + messageslist.getText(), '_blank', null);
        return true;
}-*/;

I hpe it's what you searched for...

Danny

2008/11/20 darkflame <dark...@gmail.com>

darkflame

unread,
Nov 21, 2008, 7:50:02 AM11/21/08
to Google Web Toolkit
Thats still using the string by the URL though/"get method", which
limits the charecfters to about 100 :-/

Is it possible to do the same thing but not have the data in the url,
so it could be picked up by the php's post variable instead?
(which you can do with RequestBuilder by using new RequestBuilder
(RequestBuilder.POST....) but that dosnt open a new window.)

On Nov 21, 8:13 am, "Danny Schimke" <schimk...@googlemail.com> wrote:
> You could try to use JSNI to open a new window as you've already done:
>
> It should look something like this:
>
> native JavaScriptObject openWindow(String param) /*-{
>         $wnd.open('scripts/display.php' + '?text=' + messageslist.getText(),
> '_blank', null);
>         return true;}-*/;
>
> I hpe it's what you searched for...
>
> Danny
>
> 2008/11/20 darkflame <darkfl...@gmail.com>

darkflame

unread,
Nov 21, 2008, 2:10:02 PM11/21/08
to Google Web Toolkit
Just thinking outloud here...it could be done with a form right? Just
hidden somewhere.
dosnt seem very neat though.

darkflame

unread,
Dec 2, 2008, 1:48:56 PM12/2/08
to Google Web Toolkit
nope..apperently I cant use a form panel to post data to a new
window :-/

I'm happy to use any combination of php and gwt, but I cant seem to
find a neat way to get a string (of decent length) into a new window.

I could save to cookie or something, but that seems a very messy
method to use :-/

On Nov 21, 8:10 pm, darkflame <darkfl...@gmail.com> wrote:
> Just thinking outloud here...it could be done with a form right? Just
> hidden somewhere.
> dosnt seem very neat though.
>
> On Nov 21, 1:50 pm, darkflame <darkfl...@gmail.com> wrote:
>
> > Thats still using the string by the URL though/"get method", which
> > limits the charecfters to about  100  :-/
>
> > Is it possible to do the same thing but not have the data in the url,
> > so it could be picked up by the php'spostvariable instead?
> > (which you can do with RequestBuilder by using  new RequestBuilder
> > (RequestBuilder.POST....) but that dosnt open a newwindow.)
>
> > On Nov 21, 8:13 am, "Danny Schimke" <schimk...@googlemail.com> wrote:
>
> > > You could try to use JSNI to open a newwindowas you've already done:
>
> > > It should look something like this:
>
> > > native JavaScriptObject openWindow(String param) /*-{
> > >         $wnd.open('scripts/display.php' + '?text=' + messageslist.getText(),
> > > '_blank', null);
> > >         return true;}-*/;
>
> > > I hpe it's what you searched for...
>
> > > Danny
>
> > > 2008/11/20 darkflame <darkfl...@gmail.com>
>
> > > > Any ideas?
> > > > The text is dynamic, so I thought at first I'd just use;
>
> > > >Window.open("scripts/display.php"+"?text="+messageslist.getText(),
> > > > "_blank", null);
>
> > > > Where display.php simply gets the text variable in the url and echo's
> > > > it back.
>
> > > > However, this has a very short limit on the text that can be
> > > > displayed.
> > > > Is it possible to do a simerla function with RequestBuilder? SoPost
> > > > can be used correctly?
> > > > I have no idea if its possible to use RequestBuilder to open a php in
> > > > a newwindow, so if it isn't I would welcome workarounds if its not.
>
> > > > Cheers,

alex.d

unread,
Dec 3, 2008, 2:42:57 AM12/3/08
to Google Web Toolkit
In good old javascript time i've done this like:
var popup = $wnd.open('scripts/display.php', '_blank', null);
popup.getElementById('idShowText')... // Hier get a div or smth. and
show/insert your text

Thomas Wrobel

unread,
Dec 3, 2008, 10:12:16 AM12/3/08
to Google-We...@googlegroups.com
Must admit, I wasnt aware you could set text in another window from a
script running in the current one.

Still, dosnt seem to work for me
display.php has the following html;

<html>
<body>
<div id="idShowText">test</div>
</body>
</html>

And my native javascript being triggered is;

var popup = $wnd.open('scripts/printthis.php', '_blank', null);
popup.getElementById('idShowText').innerHTML="someText";

return;


The window pops up ok, but the text remains just "test", and dosnt
change to "someText".



2008/12/3 alex.d <alex.du...@googlemail.com>:

alex.d

unread,
Dec 3, 2008, 11:08:24 AM12/3/08
to Google Web Toolkit
Not quite sure why this doesn't work - try to play with it in FireBug
(you can open your window from the console and use popup-variable to
get it's elements). Does popup.getElementById('idShowText') give en
element back?

On 3 Dez., 16:12, "Thomas Wrobel" <darkfl...@gmail.com> wrote:
> Must admit, I wasnt aware you could set text in another window from a
> script running in the current one.
>
> Still, dosnt seem to work for me
> display.php has the following html;
>
> <html>
> <body>
> <div id="idShowText">test</div>
> </body>
> </html>
>
> And my native javascript being triggered is;
>
> var popup = $wnd.open('scripts/printthis.php', '_blank', null);
>                 popup.getElementById('idShowText').innerHTML="someText";
>
>             return;
>
> The window pops up ok, but the text remains just "test", and dosnt
> change to "someText".
>
> 2008/12/3 alex.d <alex.dukhov...@googlemail.com>:

Thomas Wrobel

unread,
Dec 3, 2008, 11:45:22 AM12/3/08
to Google-We...@googlegroups.com
If I type;

var popup = document.open('scripts/display.php', '_blank', null);
into the console of my gwt the new window pops up.

Then typeing;

popup.getElementById('idShowText')

Results in;

TypeError: popup.getElementById is not a function

(I also tried with .innerHTML("teststrng") at the end, but that gave
the same result)

Its worth noteing that ;
document.write(popup.title);
or
document.write(popup.url);

both return undefined. (despite that a title is set).

It seems popup just isnt refering to the newly created window.


~~~~~~
Reviews of anything, by anyone;
www.rateoholic.co.uk
Please try out my new site and give feedback :)



2008/12/3 alex.d <alex.du...@googlemail.com>:

alex.d

unread,
Dec 4, 2008, 2:54:50 AM12/4/08
to Google Web Toolkit
Sorry - it was a long day yesterday ;-)
popup is actually your new Window and getElementById() is the Function
that belongs to the Document object - not the Window object. So it
should be popup.document.getElementById()... And from your popup-
Window you can call window.opener.document.getElementById() to access
the parent window.

On 3 Dez., 17:45, "Thomas Wrobel" <darkfl...@gmail.com> wrote:
> If  I type;
>
> var popup = document.open('scripts/display.php', '_blank', null);
> into the console of my gwt the new window pops up.
>
> Then typeing;
>
> popup.getElementById('idShowText')
>
> Results in;
>
> TypeError: popup.getElementById is not a function
>
> (I also tried with .innerHTML("teststrng") at the end, but that gave
> the same result)
>
> Its worth noteing that ;
>  document.write(popup.title);
> or
>  document.write(popup.url);
>
> both return undefined. (despite that a title is set).
>
> It seems popup just isnt refering to the newly created window.
>
> ~~~~~~
> Reviews of anything, by anyone;www.rateoholic.co.uk
> Please try out my new site and give feedback :)
>
> 2008/12/3 alex.d <alex.dukhov...@googlemail.com>:

Thomas Wrobel

unread,
Dec 4, 2008, 10:23:45 AM12/4/08
to Google-We...@googlegroups.com
thanks for your help, thats better, but still no luck.

This time it gives me a ;

com_darkflame_client_MessageHistory_$popupWindowWithString__Lcom_darkflame_client_MessageHistory_2Ljava_lang_String_2_popup_0.document.getElementById($intern_324)
is null

error when run ver gwt.
(my gwt line is now;
popup.document.getElementById('idShowText').innerHTML="someText";
)


When typed directly at the console using firebug I get;

[Exception... "Cannot modify properties of a WrappedNative" nsresult:
"0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame
:: http://www.cuyperscode.com/CuypersCode2_WIP/CuypersCode2.html ::
anonymous :: line 91" data: no]

Any ideas?

Bit out of my depth here, I foolishly thought this would be simple ;)

2008/12/4 alex.d <alex.du...@googlemail.com>:
Reply all
Reply to author
Forward
0 new messages