Cross Domain with window.name

93 views
Skip to first unread message

Chris

unread,
Jun 14, 2009, 4:25:02 AM6/14/09
to Google Web Toolkit
I am trying to get a cross domain solution working using Ray
Cromwell's solution. Has anyone gotten this to work with GWT 1.6?
Any samples out there showing how it is supposed to be wired up.

I can't seem to get the post result to be available in the
application. When the FormPanel creates the iframe, it is
automatically setting the window.name of the iframe. No matter what I
try (see below) the only value I am getting in my:
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler(){
public void onSubmitComplete(SubmitCompleteEvent event){
Window.alert("return:" + event.getResults());
}
});

Is the preset iframe window.name. Something like FormaPanel_1.

I've tried having the servlet on the cross domain return variations
of:
<script>...</script>
<html><script>...</script></html>
<html><head><script>...</script><head></html>

Any ideas on what I could be doing wrong?

The two reference articles I have been using:
http://timepedia.blogspot.com/2008/07/cross-domain-formpanel-submissions-in.html
http://development.lombardi.com/?p=611

Thanks,
Chris.....

My sample code:

public class Zwidget2 implements EntryPoint{
FormPanel form;
public void onModuleLoad(){
final Button sendButton = new Button("Send To Cross Domain");

RootPanel.get("btn4").add(sendButton);

class MySendHandler implements ClickHandler{
public void onClick(ClickEvent event){
if(form != null) {
RootPanel.get("form1").remove(form);
}
form = new FormPanel();

form.setAction("http://crossdomain.com/zwidget2/greet2");
form.setMethod(FormPanel.METHOD_POST);

Hidden h = new Hidden();
h.setValue(variable());
h.setName("inputvalue");
form.add(h);

form.addSubmitHandler(new FormPanel.SubmitHandler(){
public void onSubmit(SubmitEvent event){
Window.alert("submit form with value[" + variable()
+ "] to url[" + form.getAction() + "]");
}
});
form.addSubmitCompleteHandler(new
FormPanel.SubmitCompleteHandler(){
public void onSubmitComplete(SubmitCompleteEvent event)
{
Window.alert("return:" + event.getResults());
}
});

RootPanel.get("form1").add(form); //form needs to be
attached to send

DeferredCommand.addCommand(new Command(){
public void execute(){
Window.alert("submit");
form.submit();
}
});
}
}

sendButton.addClickHandler(new MySendHandler());
}

public native String variable()/*-{
return $wnd.__myVariable; //set by another javascript script
}-*/;
}

Chris

unread,
Jun 15, 2009, 9:56:29 AM6/15/09
to Google Web Toolkit
I quick followup. It appears the code (modified for IE) works on IE
6. The trouble I am having is with FireFox 3.0.10.

Does any know if the code should work with FF3? Is there some
restricted access to window.name on FF?

Thanks,
Chris....

On Jun 14, 4:25 am, Chris <chrish...@gmail.com> wrote:
> I am trying to get a cross domain solution working using Ray
> Cromwell's solution.  Has anyone gotten this to work with GWT 1.6?
> Any samples out there showing how it is supposed to be wired up.
>
> I can't seem to get the post result to be available in the
> application.  When the FormPanel creates the iframe, it is
> automatically setting the window.name of the iframe.  No matter what I
> try (see below) the only value I am getting in my:
> form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler(){
>    public void onSubmitComplete(SubmitCompleteEvent event){
>       Window.alert("return:" + event.getResults());
>    }
>
> });
>
> Is the preset iframe window.name.  Something like FormaPanel_1.
>
> I've tried having the servlet on the cross domain return variations
> of:
> <script>...</script>
> <html><script>...</script></html>
> <html><head><script>...</script><head></html>
>
> Any ideas on what I could be doing wrong?
>
> The two reference articles I have been using:http://timepedia.blogspot.com/2008/07/cross-domain-formpanel-submissi...http://development.lombardi.com/?p=611

Chris

unread,
Jun 17, 2009, 4:53:44 PM6/17/09
to Google Web Toolkit
I guess I'm getting one step closer; but still no solution to make
this work.

If I return the script:

<html>
<script>
alert('Hi');
</script>
</html>

IE 6 will run that script. Firefox 3 will not. Any thoughts?

Thanks,
Chris....
Reply all
Reply to author
Forward
0 new messages