Re: [wicket newbie] - appending query parameter to ajax link
override getcallbackscript(boolean) and return something like: return generateCallbackScript(wicketAjaxGet(' + getCallbackUrl() + myparam='+Wicket.$(id of component).value); -igor On Mon, Sep 13, 2010 at 7:23 AM, nimmy nim_sa...@hotmail.com wrote: Hi Guys, I'm trying to implement the typical 'check availability' functionality for a username. I have an IndicatingAjaxFallbackLink. I would like to append the value of a form component [username TextField] to the ajax link as a query parameter. I've tried: 1. overriding onComponentTag in the IndicatingAjaxFallbackLink but I do not get access to the getCallbackUrl method 2. add an AbstractDefaultAjaxBehaviour but: 1. End up with onEvent and onClick and don't know where to put the serverside logic. 2. Am not able to get the param value from RequestCycle. The only method that works for me is to submit the whole form without validation and get the value from the textfield on the serverside. I would prefer not to submit the whole form. Appreciate your help with this. Cheers, Nim -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2537522.html Sent from the Wicket - User 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: [wicket newbie] - appending query parameter to ajax link
I think its easier to attach an ajax behaviour to the text field (like onkeyup) that will push the changes to wicket for validation. You can use target.addComponent(indicator) to get the indication to be shown based on the results of the validation. Look at subclassing AjaxFormComponentUpdatingBehavior which can push the single field value through to wicket for processing. You might be able to append the parameter by implementing: protected IAjaxCallDecorator getAjaxCallDecorator() { return null; } in your IndicatingAjaxFallbackLink sub class. But the easiest way is to modify the getCallbackUrl method in the behaviour itself. something like this: (I assume that a Component targetComponent is a private field) @Override protected final CharSequence getCallbackScript(boolean onlyTargetActivePage) { /* * Encode the callback script appending to the url the current client side value of the component values. */ CharSequence baseUrl = super.getCallbackUrl(onlyTargetActivePage); String callbackScript = baseUrl + value='+Wicket.$(' + targetComponent.getMarkupId() + ').value; String script = wicketAjaxGet(' + callbackScript + );; return script; } This will create urlvalue=Wicket.$(targetComponent.markupID).value The second part is to fetch the value parameter on the wicket side and process it: Request request = RequestCycle.get().getRequest(); String value = request.getParameter(value); Regards, Mike Hi Guys, I'm trying to implement the typical 'check availability' functionality for a username. I have an IndicatingAjaxFallbackLink. I would like to append the value of a form component [username TextField] to the ajax link as a query parameter. I've tried: 1. overriding onComponentTag in the IndicatingAjaxFallbackLink but I do not get access to the getCallbackUrl method 2. add an AbstractDefaultAjaxBehaviour but: 1. End up with onEvent and onClick and don't know where to put the serverside logic. 2. Am not able to get the param value from RequestCycle. The only method that works for me is to submit the whole form without validation and get the value from the textfield on the serverside. I would prefer not to submit the whole form. Appreciate your help with this. Cheers, Nim - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: [wicket newbie] - appending query parameter to ajax link
Thanks for your help Igor. It worked like a charm. For other readers new to wicket : 1. add an AjaxEventBehaviour(onclick) to the IndicatingAjaxFallbackLink 2. Override getCallbackScript to append the param values as described in the email below 3. Do your server side processing in the onEvent method of the AjaxEventBehaviour and not on the onSubmit method of the IndicatingAjaxFallbackLink Cheers, Nim Date: Mon, 13 Sep 2010 08:15:42 -0700 From: ml-node+2537614-574240720-160...@n4.nabble.com To: nim_sa...@hotmail.com Subject: Re: [wicket newbie] - appending query parameter to ajax link override getcallbackscript(boolean) and return something like: return generateCallbackScript(wicketAjaxGet(' + getCallbackUrl() + myparam='+Wicket.$(id of component).value); -igor On Mon, Sep 13, 2010 at 7:23 AM, nimmy [hidden email] wrote: Hi Guys, I'm trying to implement the typical 'check availability' functionality for a username. I have an IndicatingAjaxFallbackLink. I would like to append the value of a form component [username TextField] to the ajax link as a query parameter. I've tried: 1. overriding onComponentTag in the IndicatingAjaxFallbackLink but I do not get access to the getCallbackUrl method 2. add an AbstractDefaultAjaxBehaviour but: 1. End up with onEvent and onClick and don't know where to put the serverside logic. 2. Am not able to get the param value from RequestCycle. The only method that works for me is to submit the whole form without validation and get the value from the textfield on the serverside. I would prefer not to submit the whole form. Appreciate your help with this. Cheers, Nim -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2537522.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] - To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] View message @ http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2537614.html To unsubscribe from [wicket newbie] - appending query parameter to ajax link, click here. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2537685.html Sent from the Wicket - User mailing list archive at Nabble.com.
RE: [wicket newbie] - appending query parameter to ajax link
Thanks for your help Mike Date: Mon, 13 Sep 2010 08:32:00 -0700 From: ml-node+2537637-1380929500-160...@n4.nabble.com To: nim_sa...@hotmail.com Subject: Re: [wicket newbie] - appending query parameter to ajax link I think its easier to attach an ajax behaviour to the text field (like onkeyup) that will push the changes to wicket for validation. You can use target.addComponent(indicator) to get the indication to be shown based on the results of the validation. Look at subclassing AjaxFormComponentUpdatingBehavior which can push the single field value through to wicket for processing. You might be able to append the parameter by implementing: protected IAjaxCallDecorator getAjaxCallDecorator() { return null; } in your IndicatingAjaxFallbackLink sub class. But the easiest way is to modify the getCallbackUrl method in the behaviour itself. something like this: (I assume that a Component targetComponent is a private field) @Override protected final CharSequence getCallbackScript(boolean onlyTargetActivePage) { /* * Encode the callback script appending to the url the current client side value of the component values. */ CharSequence baseUrl = super.getCallbackUrl(onlyTargetActivePage); String callbackScript = baseUrl + value='+Wicket.$(' + targetComponent.getMarkupId() + ').value; String script = wicketAjaxGet(' + callbackScript + );; return script; } This will create urlvalue=Wicket.$(targetComponent.markupID).value The second part is to fetch the value parameter on the wicket side and process it: Request request = RequestCycle.get().getRequest(); String value = request.getParameter(value); Regards, Mike Hi Guys, I'm trying to implement the typical 'check availability' functionality for a username. I have an IndicatingAjaxFallbackLink. I would like to append the value of a form component [username TextField] to the ajax link as a query parameter. I've tried: 1. overriding onComponentTag in the IndicatingAjaxFallbackLink but I do not get access to the getCallbackUrl method 2. add an AbstractDefaultAjaxBehaviour but: 1. End up with onEvent and onClick and don't know where to put the serverside logic. 2. Am not able to get the param value from RequestCycle. The only method that works for me is to submit the whole form without validation and get the value from the textfield on the serverside. I would prefer not to submit the whole form. Appreciate your help with this. Cheers, Nim - To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] View message @ http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2537637.html To unsubscribe from [wicket newbie] - appending query parameter to ajax link, click here. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-newbie-appending-query-parameter-to-ajax-link-tp2537522p2538012.html Sent from the Wicket - User mailing list archive at Nabble.com.