Wednesday, May 8, 2013

Re: SubmitCompleteEvent.getResults() always returns null

OK,

I realized what I'm doing is a cross-domain call, thanks to "@tip, the result html can be null as a result of submitting a form to a different domain."

However, how do I solve this thing out? I really don't know what to do...


Em quarta-feira, 8 de maio de 2013 12h09min56s UTC-3, Robson Braga escreveu:
Hi guys,

I've a RESTful webservice that returns xml/json and it works properly.

If I submit a HTML form to that webservice, Firefox and Chrome shows the XML file, but when I try to submit a GWT FormPanel, on the onSubmitComplete callback, SubmitCompleteEvent.getResults() always returns null.

Here is my HTML code:

<html>
    <body>
        <form method="POST" action="http://localhost:8080/myWebService/entry">
            <input type="email" id="email" name="email" width="10"><br>
            <input type="password" id="password" name="password" width="10"><br>
            <input type="submit" value="Test">
        </form>
    </body>
</html>


Here is my GWT Code:

    public void onModuleLoad() {
        final FormPanel formPanel = new FormPanel();
        formPanel.setEncoding(FormPanel.ENCODING_URLENCODED);
        formPanel.setMethod(FormPanel.METHOD_POST);

        VerticalPanel verticalPanel = new VerticalPanel();

        verticalPanel.add(new Label("Username"));
        TextBox userid = new TextBox();
        userid.setName("email");
        verticalPanel.add(userid);

        verticalPanel.add(new Label("Password"));
        PasswordTextBox passwd = new PasswordTextBox();
        passwd.setName("password");
        verticalPanel.add(passwd);

        verticalPanel.add(new Button("Submit", new ClickHandler() {
            public void onClick(ClickEvent event) {
                formPanel.submit();
            }
        }));

        formPanel.add(verticalPanel);
        formPanel.setAction("http://localhost:8080/
myWebService/entry");
        formPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
               Window.alert(event.getResults());
            }
        });

        RootPanel.get().add(formPanel);   
    }


What am I doing wrong? Am I forgetting something? Is there any SOP restriction? How do I bypass this issue?

Thanks in advance.

--
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+unsubscribe@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate