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 url&value=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.

Reply via email to