Hi,The following (based on your answer, but then 'backported' to 1.4) seems to work: I basically copied the implementation of executeBehavior from WicketTester.
public void executeBehaviorWithParameters(AbstractAjaxBehavior behavior, Map<String, ?> parameters) { StringBuffer url = new StringBuffer(behavior.getCallbackUrl(false));
for (Map.Entry<String, ?> entry : parameters.entrySet()) { try { url.append('&'); url.append(URLEncoder.encode(entry.getKey(), "UTF-8")); url.append('='); url.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8")); } catch (UnsupportedEncodingException e) { // Should not happen. throw new RuntimeException(e); } } WebRequestCycle cycle = tester.setupRequestAndResponse(true); tester.getServletRequest().setRequestToRedirectString(url.toString()); tester.processRequestCycle(cycle); } Regards, Sebastiaan On 11/28/2011 08:20 AM, Sebastiaan van Erk wrote:
Hi, Thanks for your answer. Unfortunately for the moment I don't have the opportunity to upgrade to Wicket 1.5 on this project. Is there a way to achieve this using Wicket 1.4? If not, I can live with it, but it would be nice if possible. Best regards, Sebastiaan On 11/28/2011 07:35 AM, Martin Grigorov wrote:Hi, With Wicket 1.5 you can use executeUrl() to do that. p = startPage c = p.get("....") b = c.getBehaviorByXyz() u = b.getCallbackUrl() fullUrl = u + "&foo=bar&wicket-ajax=true" executeUrl(fullUrl) On Mon, Nov 28, 2011 at 6:59 AM, Sebastiaan van Erk<sebs...@sebster.com> wrote:Hi all, I've got a page which calls wicket from javascript as described by the page: https://cwiki.apache.org/WICKET/calling-wicket-from-javascript.html That is, in my JavaScript I call a function: function callWicket() { var wcall = wicketAjaxGet('$url$' + '$args$', function() { }, function() { }); } The args are of the form "&foo=bar" as described. I also retrieve this argument when I receive the call in Wicket using (also as described): String paramFoo = RequestCycle.get().getRequest().getParameter("foo"); However, I'm wondering, how can I test this using WicketTester? I first use startPage to render the page, but how can I now simulate the wicketAjaxGet, and how can I make sure the parameter is set on the request so paramFoo does not end up being null? Best regards, Sebastiaan
smime.p7s
Description: S/MIME Cryptographic Signature