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 <ajax-response></ajax-response>. My page has a ListView with a number of labels, like this <div id="myContainer" wicket:id="myContainer"> <div class="myUser" wicket:id="myList"> </div> <div id="aResult" wicket:id="aResult" ></div> </div> 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<Integer> nrs = new ArrayList<Integer>(); 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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org