You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by monzonj <mo...@gmail.com> on 2010/09/15 13:22:07 UTC

Wicket 1.5-m1 - Redirect from AJAX doesn't work.

Hi.
I've I have understood correctly, it is possible to redirect to a new page
during an AJAX request (this is not trivial to do with an standard
XHMLHttpRequest, but Wicket seems to have found a way). The thing is that it
doesn't work for Wicket 1.5. Let me illustrate the case with a working
example.

Consider an application with only two pages:

MockHomePage.java
---------------------
public class MockHomePage extends WebPage {
    public MockHomePage() {

        final Form<String> form = new Form<String>("myForm");
        add(form);

        form.add(new AjaxButton("myButton", form) {
            @Override
            protected void onSubmit(final AjaxRequestTarget target, final
Form<?> form) {
                 setResponsePage(MockPage.class);
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final
Form<?> form) {
                throw new RuntimeException("Uh oh!");
            }
        });
    }
}

MockHomePage.html
--------------------
<body>
    <form wicket:id="myForm">
        <input type="submit" wicket:id="myButton" value="Submit"/>
    </form>
</body>


MockPage.java
---------------
public class MockPage extends WebPage {
    public MockPage() {
    }
}

MockPage.html
--------------
<body>
    <div>Hi</div>
</body>


Quite simple, and in your WebApplication class:

Application.java
---------------
public class Application extends WebApplication {
    @Override
    public Class<? extends Page> getHomePage() {
        return MockHomePage.class;
    }
}


This is a very simple straight forward page. Please, notice that in file ''
I'm using 'setResponsePage(MockPage.class);' which sould redirect to the
second page. But it doesn't; I stay in the same page and the Wicket Ajax
debugger on screen prints:

INFO: focus set on myButton2
INFO:
INFO: Initiating Ajax POST request on
../page;jsessionid=33050120F7986EC9D41FE3999A1D7F64?0-1.IBehaviorListener.0-myForm-myButton&random=0.34360759755785986
INFO: Invoking pre-call handler(s)...
INFO: Received ajax response (321 characters)
INFO:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:wicket="http://wicket.apache.org/"
        xml:lang="en"
        lang="en">
<body>
    <div>Hi</div>
</body>
</html>
ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Could not
find root <ajax-response> element
INFO: Invoking post-call handler(s)...
INFO: Invoking failure handler(s)...
INFO: focus removed from myButton2


I guess something is broken or really redirections cannot take place on Ajax
requests. 

A helpful hand would be mostly appreciated.




-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-m1-Redirect-from-AJAX-doesn-t-work-tp2540344p2540344.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket 1.5-m1 - Redirect from AJAX doesn't work.

Posted by monzonj <mo...@gmail.com>.
Done
https://issues.apache.org/jira/browse/WICKET-3048


> Can you file an JIRA issue please?
>
>
> Am 15.09.2010 um 13:26 schrieb monzonj: 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-m1-Redirect-from-AJAX-doesn-t-work-tp2540344p2540384.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket 1.5-m1 - Redirect from AJAX doesn't work.

Posted by Peter Ertl <pe...@gmx.org>.
Can you file an JIRA issue please?


Am 15.09.2010 um 13:26 schrieb monzonj:

> 
> Hi,
> 
> I would like to point out that I've tried with Wicket 1.4.10 and it works
> fine. So, it's a bug on Wicket 1.5
> -- 
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-m1-Redirect-from-AJAX-doesn-t-work-tp2540344p2540352.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket 1.5-m1 - Redirect from AJAX doesn't work.

Posted by monzonj <mo...@gmail.com>.
Hi,

I would like to point out that I've tried with Wicket 1.4.10 and it works
fine. So, it's a bug on Wicket 1.5
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-m1-Redirect-from-AJAX-doesn-t-work-tp2540344p2540352.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org