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 FormString form = new FormString(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
divHi/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-myButtonrandom=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
divHi/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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org