Can Wicket handle two requests from the same page within the same session concurrently?
When I click on link 1 and then, before the respons开发者_Python百科e was received, click on link 2 on the same page, I get a "Page Expired" error from Wicket. Is Wicket conceptional capable to do such a concurrent processing?
Any ideas why Wicket loses the session (it seems to reside on tomcat though)?
To answer the question myself: It seems like Wicket has no problem to process a second link click while the first is still beeing processed. I tried it with the following example.
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
public class ConcurrentClickPage extends WebPage {
public ConcurrentClickPage() {
final IModel<String> model = new Model<String>("initial");
Label status = new Label("status", model);
add(status);
add(new Link("link1"){
@Override
public void onClick() {
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
Logger.getLogger(ConcurrentClickPage.class.getName()).log(Level.SEVERE, null, ex);
}
model.setObject("link 1 clicked");
}
});
add(new Link("link2"){
@Override
public void onClick() {
model.setObject("link 2 clicked");
}
});
}
}
And the corresponding html page:
<html>
<body>
<span wicket:id="status">text</span>
<p>
<a href="#" wicket:id="link1">Link 1 (deferred processing)</a><br/>
<a href="#" wicket:id="link2">Link 2</a>
</p>
</body>
</html>
When I click on link 1 and click on link 2 while waiting on the response of link 1, everything is fine and I get no "page expired" error.
精彩评论