Passing a parameter into a frame

676 views
Skip to first unread message

rvd

unread,
Oct 3, 2007, 8:27:54 AM10/3/07
to Google Web Toolkit
Not having much luck on this one.

Is there a way to pass a parameter from outside a Frame to something
running inside a Frame? Query parameters on the frame creation url do
not work.

Reinier Zwitserloot

unread,
Oct 3, 2007, 4:45:13 PM10/3/07
to Google Web Toolkit
... but they should. Did you try the #? Is it the same Domain? In that
case you can just communicate with it through javascript (JSNI).

rvd

unread,
Oct 4, 2007, 10:13:58 AM10/4/07
to Google Web Toolkit
I have two projects. One is http://www.netrocam.com/homesite/Homesite.html
and one is http://www.netrocam.com/runviewer/RunViewer.html.

The fact that they are two projects is just a convenience to me, so
that I can break up a larger item into smaller items. On the menu of
the homesite project, there is an entry to view races, which causes
the second url to be loaded into a frame of the first one. There are
also entries to view training runs or a comparison between gps
devices.

On the second url mentioned above I could type:
http://www.netrocam.com/runviewer/RunViewer.html?runType=training or ?
runType=comparison. (There is also runType=races, but that is the
default). These request parameters work fine when executed from the
second url. But, when I attempt to pass them from the first
application with

String pageURL = "http://www.netrocam.com/runviewer/RunViewer.html?
runType=training"

Frame bodyFrame = new Frame(pageURL);

The request parameter seems not to be passed to the second
application. In the second application I am attempting to get the
parameter by calling the following:

public native String getQueryString()/*-{
return window.top.location.search.toString();
}-*/;

but this returns an empty string.

I don't know of any other way to pass values from the first
application to the second one without goint to LOTS of trouble, like
uploading the request to a database and then checking the database
when the second application is launched, etc.

I would be grateful for any ideas.

Peter Blazejewicz

unread,
Oct 4, 2007, 5:20:14 PM10/4/07
to Google Web Toolkit
hi,

>> I would be grateful for any ideas.

off: I think others would be greatful if you don't start new thread
for the same topic because you think you haven't received satisfactory
answer in your other two threads. Simply add new entry to your other
threads instead of starting new one,

I again tested your issue and I'm able to pass url+params to iframe
(tested in IE/FF/Safari windows) though frame content behavior
differes due to different domain policy (I've tested from running on
localhost),:

package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestIFrame implements EntryPoint {
private Button clickMeButton;

public void onModuleLoad() {
final RootPanel rootPanel = RootPanel.get();

clickMeButton = new Button();
rootPanel.add(clickMeButton);
clickMeButton.setText("Click me!");
clickMeButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
rootPanel.remove(clickMeButton);
Frame iFrame = new Frame() {
public void onBrowserEvent(Event event) {
if (DOM.eventGetType(event) == Event.ONLOAD) {
Window.alert("url: " + this.getUrl());
}
super.onBrowserEvent(event);
}
};
rootPanel.add(iFrame);
iFrame.sinkEvents(Event.ONLOAD);
iFrame.setSize("100%", "100%");
String url = "http://www.netrocam.com/runviewer/RunViewer.html?
runType=training";
iFrame.setUrl(url);
}
});
}
}

here is content of your frame taken from Safari:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-
microsoft-com:vml">
<head>
<title>RunViewer</title>
<meta name='gwt:module' content='RunViewer'>
<link rel="stylesheet" href="RunViewer.css">
<style type="text/css">
v\:* {
behavior:url(#default#VML);
}
</style>
<script type="text/javascript"
src="http://maps.google.com/maps?
file=api&amp;v=2.x&amp;key=ABQIAAAA3pDFjGXx0dUPlqOV5wUzbhTGcmFu162Gy9wprnCT-
UoaWa9H0xTo9IuQLf9brY_iF2G2ffEjqGZf0A">
</script>


</head>
<body>
<script language="javascript" src="gwt.js"></script>
<iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></
iframe>
</body>
</html>

now I wonder what are your results? maybe your script is not loading
or something into your frame?


regards,
Peter

On Oct 4, 4:13 pm, rvd <r...@netrocam.com> wrote:
> I have two projects. One ishttp://www.netrocam.com/homesite/Homesite.html

> and one ishttp://www.netrocam.com/runviewer/RunViewer.html.


>
> The fact that they are two projects is just a convenience to me, so
> that I can break up a larger item into smaller items. On the menu of
> the homesite project, there is an entry to view races, which causes
> the second url to be loaded into a frame of the first one. There are
> also entries to view training runs or a comparison between gps
> devices.
>

> On the second url mentioned above I could type:http://www.netrocam.com/runviewer/RunViewer.html?runType=trainingor ?

Rich

unread,
Oct 4, 2007, 7:18:55 PM10/4/07
to Google Web Toolkit
Clearly one can do a setUrl followed by a getURl and retrieve the
url. However, unfortunately, that is not the problem as described, in
which the issue is passing the query parameter across applications.
One does not have a "getUrl()" method available in the destination
application, because the destination application does not know about a
frame.

If one executes http://www.netrocam.com/runviewer/RunViewer.html?runType=training
one can see "?runType=training" concatenated onto the end of the text
in the large text list box. This is just a test. However, if one
executes http://www.netrocam.com/homesite/Homesite.html and then
selects Running Stuff/View Training Courses that same parameter is
passed, but is not received at the destination. The application does
appear in the frame, and acts correctly. The only problem is that the
request parameter seems not to be retrievable. Perhaps it is because
it is associated with a frame that the destination does not know
about. I currently put up a Window.alert of the getUrl() just after
the setUrl. The Window alert does display the url, but the url still
is not accessible at the destination.

Unfortunately, I cannot test this locally because I get the error:
"[ERROR] Unable to find 'runviewer.gwt.xml' on your classpath; could
be a typo, or maybe you forgot to include a classpath entry for
source?"
So, I have to deploy to test.

regards,
Rich

Peter Blazejewicz

unread,
Oct 4, 2007, 7:51:15 PM10/4/07
to Google Web Toolkit
hi Rich,

also try passing params via Form submission with hidden field, maybe
that will work fine:

package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestIFrame implements EntryPoint {
private Button clickMeButton;

public void onModuleLoad() {
final RootPanel rootPanel = RootPanel.get();

clickMeButton = new Button();
rootPanel.add(clickMeButton);
clickMeButton.setText("Click me!");
clickMeButton.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
rootPanel.remove(clickMeButton);

NamedFrame iFrame = new NamedFrame("viewFrame");
rootPanel.add(iFrame);


iFrame.setSize("100%", "100%");

FormPanel f = new FormPanel(iFrame);
f.setAction("http://www.netrocam.com/runviewer/RunViewer.html");
f.setEncoding(FormPanel.ENCODING_URLENCODED);
f.setMethod(FormPanel.METHOD_GET);
Hidden h = new Hidden();
h.setName("runType");
h.setValue("training");
f.add(h);
f.setVisible(false);
rootPanel.add(f);
f.submit();
}
});
}
}


regards,
peter

On Oct 5, 1:18 am, Rich <RVDown...@gmail.com> wrote:
> Clearly one can do a setUrl followed by a getURl and retrieve the
> url. However, unfortunately, that is not the problem as described, in
> which the issue is passing the query parameter across applications.
> One does not have a "getUrl()" method available in the destination
> application, because the destination application does not know about a
> frame.
>

> If one executeshttp://www.netrocam.com/runviewer/RunViewer.html?runType=training


> one can see "?runType=training" concatenated onto the end of the text
> in the large text list box. This is just a test. However, if one

> executeshttp://www.netrocam.com/homesite/Homesite.htmland then

Rich

unread,
Oct 4, 2007, 9:10:40 PM10/4/07
to Google Web Toolkit
Still don't see how the destination application is supposed to access
this hidden field. Are you suggesting that the server should get the
contents of this hidden field, perhaps put it into a database and wait
for a call for the variable by the second application? That is not
much different from not using a form and just using RPC to upload the
data string -- just a bit of a different method of moving the string
to the server.

Regards,
Rich

Rich

unread,
Oct 4, 2007, 11:04:47 PM10/4/07
to Google Web Toolkit
I also tried using a cookie, but the destination application can't get
the cookie that the source application set. Don't really know why.
Isn't the domain the same -- netrocam.com? or does the directory
matter also? Anyway, it didn't work. It shouldn't be this difficult
to pass a parameter.

Peter Blazejewicz

unread,
Oct 4, 2007, 11:33:30 PM10/4/07
to Google Web Toolkit
hi Rich,
hidden fields are simply passed to iframe named target with from post,
maybe that's because of accessing iframe location in wrong way?
http://www.quirksmode.org/js/iframe.html

regards,
Peeter

Rich

unread,
Oct 5, 2007, 7:25:34 AM10/5/07
to Google Web Toolkit
Peter,

How does the destination application access the iframe? Isn't the
iframe outside of its "universe?"

rvd

unread,
Oct 5, 2007, 8:51:52 AM10/5/07
to Google Web Toolkit
Seems my last response didn't get posted.

It is good that they are passed to the iframe. Unfortunately, the
destination application doesn't know anything about the iframe. The
iframe is outside its "universe." If the destination application could
access the iframe, then the simple getUrl() would work.

I think all the difficulties are caused by the inability of the
destination application to access the iframe, and also that the
request parameters are not passed to the destination application as
part of the url with the setUrl or the Frame constructor.

I'm beginning to think that you just "can't get there from here."

Regards,
Rich

Reply all
Reply to author
Forward
0 new messages