Return-Path: X-Original-To: apmail-wicket-users-archive@minotaur.apache.org Delivered-To: apmail-wicket-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E2FEF12E for ; Wed, 3 Apr 2013 17:58:54 +0000 (UTC) Received: (qmail 95221 invoked by uid 500); 3 Apr 2013 17:58:53 -0000 Delivered-To: apmail-wicket-users-archive@wicket.apache.org Received: (qmail 95057 invoked by uid 500); 3 Apr 2013 17:58:52 -0000 Mailing-List: contact users-help@wicket.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@wicket.apache.org Delivered-To: mailing list users@wicket.apache.org Received: (qmail 95034 invoked by uid 99); 3 Apr 2013 17:58:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 17:58:52 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.126.186] (HELO moutng.kundenserver.de) (212.227.126.186) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 17:58:47 +0000 Received: from [192.168.178.21] (p54925169.dip0.t-ipconnect.de [84.146.81.105]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MFOee-1UQjBv3YFY-00ELAQ; Wed, 03 Apr 2013 19:58:12 +0200 Message-ID: <515C6DB2.7000505@meiers.net> Date: Wed, 03 Apr 2013 19:58:10 +0200 From: Sven Meier User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 To: users@wicket.apache.org Subject: Re: AbstractDefaultAjaxBehavior response handling References: <1365009254791-4657714.post@n4.nabble.com> In-Reply-To: <1365009254791-4657714.post@n4.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:IqLi7g6imPwkrO3OHs4If8HstTEiRzOG27XA1FW3dUD JlH3o6hJ27DMeZXF/UciK96LPnzycOvZLXDN35PJ82cGqM2UmV 79oj/h6+VWVJYBjXn5pG+Gt0rp6yxYe5WPp7cuM+3tQPsCmgxv Ms6hydEh3gqV746SafNfirSJJtFhncuU8XLyEiQfMrvPW56CPV pZF87vOG1J+EaAPkW3L8PqNu1QzVCRjo1rVvtSMJyLsTRyTLI/ lzDUzQVPlphuKUaLCiem6yFkwNh4mXX/iB4idriKmuZ2wGVgTu k9RzgcF3VoIZOHYXJkUXbMgH81Q49AEyboSaRKOaiiQmoA9PQ8 aoI+yLG9+8/cqSQBHUtU= X-Virus-Checked: Checked by ClamAV on apache.org See AutoCompleteBehavior on how to response with a non-. Sven On 04/03/2013 07:14 PM, heikki wrote: > hello, > > I've a question about using AbstractDefaultAjaxBehavior. I can succesfully > create some dynamic script that calls Wicket.Ajax.get(), and its respond() > is correctly invoked. However I'm not sure what's with the results of the > ajax call, I can't get to it. It seems that I receive an empty response. > > My page has a list with a number of spans that have some number for their > text; I'm trying to add an onclick to the spans that invokes the Ajax call, > passing the number of the clicked span into the Ajax URL. (This works fine.) > The Ajax response should be a (a JSON version of) the input parameterm but > it is always . > > > My page has a ListView with a number of labels, like this > >
>
> >
>
>
> > and this JS > > > > Then, my Page class has: > > public TestPage(final PageParameters parameters) { > super(parameters); > // create some numbers to display in the list > IModel myListModel = new LoadableDetachableModel() { > protected Object load() { > List nrs = new ArrayList(); > nrs.add(100);nrs.add(200);nrs.add(300); > return nrs; > } > }; > ListView myView = new ListView("myList", myListModel) { > protected void populateItem(ListItem item) { > final Integer i = (Integer) item.getModelObject(); > item.add(new Label("myLabel", i)); > } > }; > WebMarkupContainer myContainer = new > WebMarkupContainer("myContainer"); > myContainer.setOutputMarkupId(true); > myContainer.add(myView); > > // I expect the Ajax result to go here > myContainer.add(new Label("aResult", "TEXT BEFORE AJAX")); > > div.add(behave()); > add(div); > } > // this reference is so I can put the URL in a js var, in > renderHead() below > private AbstractDefaultAjaxBehavior bh ; > private AbstractDefaultAjaxBehavior behave() { > if(bh == null) { > bh = new AbstractDefaultAjaxBehavior() { > protected void respond(AjaxRequestTarget target) { > String id = > getRequest().getRequestParameters().getParameterValue("myId").toString(); > Gson gson = new Gson(); > String json = gson.toJson(id); > System.out.println("json:\n" + json); > > Label label = new Label("aResult",json); > label.setOutputMarkupId(true); > // throws NPE > //getParent().replace(label); > target.add(label); > } > protected void > updateAjaxAttributes(AjaxRequestAttributes attributes) { > super.updateAjaxAttributes(attributes); > // doesn't seem to make a difference for me > //attributes.setDataType("json"); > } > }; > } > return bh; > } > > public void renderHead(IHeaderResponse response){ > bh = behave(); > String url = "var aUrl='" + bh.getCallbackUrl() + "';"; > response.render(JavaScriptHeaderItem.forScript(url, > "wicket-ajax-aUrl")); > } > > What I expected is that the div 'aResult' text would get replaced with the > contents of the Ajax call. It doesn't happen. And as I said the Ajax > response is empty (when viewed in Firebug). > > Does anyone see what I'm missing here ? > > thanks and kind regards > Heikki Doeleman > > > > > > > -- > View this message in context: http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-response-handling-tp4657714.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