You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Frank van Lankvelt <f....@onehippo.com> on 2013/07/19 15:58:28 UTC

getCallbackFunctionBody - Wicket.Ajax.ajax?

hi all,

in the process of upgrading to wicket 6, I have to do some wicket ajax
calls from custom javascript callbacks.  The AbstractDefaultAjaxBehavior
seems to provide a bunch of tools to help me out.  But I cannot make sense
of the javadoc (& implementation) of #getCallbackFunction:

 * Generates a javascript function that can take parameters and performs an
AJAX call which
 * includes these parameters. The generated code looks like this:
 *
 * <pre>
 * function(param1, param2) {
 *    var attrs = attrsJson;
 *    var params = {'param1': param1, 'param2': param2};
 *    attrs.ep = jQuery.extend(attrs.ep, params);
 *    Wicket.Ajax.ajax(attrs);
 * }
 * </pre>

But AFAIK the last line of the generated function Wicket.Ajax.ajax(attrs)
does not do an ajax call.
It just uses jQuery to register event listeners.

So have I missed something, or is this a bug?

thanks, Frank

-- 
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

Re: getCallbackFunctionBody - Wicket.Ajax.ajax?

Posted by Frank van Lankvelt <f....@onehippo.com>.
On Mon, Jul 22, 2013 at 9:13 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> On Fri, Jul 19, 2013 at 5:10 PM, Bertrand Guay-Paquet <
> bernie@step.polymtl.ca> wrote:
>
> > Hi,
> >
> > I use the javascript generated by getCallbackFunction just fine. Here's
> an
> > actual function used as an onclick callback:
> >
> > function (event) {
> > var attrs = {"u":"./103?1-1.**IBehaviorListener.0-","i":"**veil"};
> >
>
> If there is no event (attribute 'e') in the attributes then 'domready' is
> assumed.
> I.e. Wicket.Ajax.ajax() will call Wicket.Ajax.Call.ajax() as soon as the
> component is available in the DOM. If there is no component (attribute 'c')
> then the window object is used.
>
>
thanks for explaining.  This should allow me to simplify things here and
there.

cheers, Frank


>
> > var params = {'tourAction': "1"};
> > attrs.ep = params;
> > Wicket.Ajax.ajax(attrs);
> > }
> >
> > The java code that generated it is :
> >         // Collect the extra parameters
> >         CallbackParameter[] parameters = new CallbackParameter[2];
> >         parameters[0] = CallbackParameter.context("**event");
> >         parameters[1] = CallbackParameter.resolved("**tourAction", "1");
> >
> >         // Generate callback function
> >         CharSequence callbackFunction =
> getCallbackFunction(**parameters);
> >
> > This definitely does an ajax call. I haven't looked closely at the
> > Wicket.Ajax.ajax() code, but it works fine.
> >
> > Bertrand
> >
> >
> > On 19/07/2013 9:58 AM, Frank van Lankvelt wrote:
> >
> >> hi all,
> >>
> >> in the process of upgrading to wicket 6, I have to do some wicket ajax
> >> calls from custom javascript callbacks.  The AbstractDefaultAjaxBehavior
> >> seems to provide a bunch of tools to help me out.  But I cannot make
> sense
> >> of the javadoc (& implementation) of #getCallbackFunction:
> >>
> >>   * Generates a javascript function that can take parameters and
> performs
> >> an
> >> AJAX call which
> >>   * includes these parameters. The generated code looks like this:
> >>   *
> >>   * <pre>
> >>   * function(param1, param2) {
> >>   *    var attrs = attrsJson;
> >>   *    var params = {'param1': param1, 'param2': param2};
> >>   *    attrs.ep = jQuery.extend(attrs.ep, params);
> >>   *    Wicket.Ajax.ajax(attrs);
> >>   * }
> >>   * </pre>
> >>
> >> But AFAIK the last line of the generated function
> Wicket.Ajax.ajax(attrs)
> >> does not do an ajax call.
> >> It just uses jQuery to register event listeners.
> >>
> >> So have I missed something, or is this a bug?
> >>
> >> thanks, Frank
> >>
> >>
> >
> > ------------------------------**------------------------------**---------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<
> users-unsubscribe@wicket.apache.org>
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

Re: getCallbackFunctionBody - Wicket.Ajax.ajax?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Fri, Jul 19, 2013 at 5:10 PM, Bertrand Guay-Paquet <
bernie@step.polymtl.ca> wrote:

> Hi,
>
> I use the javascript generated by getCallbackFunction just fine. Here's an
> actual function used as an onclick callback:
>
> function (event) {
> var attrs = {"u":"./103?1-1.**IBehaviorListener.0-","i":"**veil"};
>

If there is no event (attribute 'e') in the attributes then 'domready' is
assumed.
I.e. Wicket.Ajax.ajax() will call Wicket.Ajax.Call.ajax() as soon as the
component is available in the DOM. If there is no component (attribute 'c')
then the window object is used.


> var params = {'tourAction': "1"};
> attrs.ep = params;
> Wicket.Ajax.ajax(attrs);
> }
>
> The java code that generated it is :
>         // Collect the extra parameters
>         CallbackParameter[] parameters = new CallbackParameter[2];
>         parameters[0] = CallbackParameter.context("**event");
>         parameters[1] = CallbackParameter.resolved("**tourAction", "1");
>
>         // Generate callback function
>         CharSequence callbackFunction = getCallbackFunction(**parameters);
>
> This definitely does an ajax call. I haven't looked closely at the
> Wicket.Ajax.ajax() code, but it works fine.
>
> Bertrand
>
>
> On 19/07/2013 9:58 AM, Frank van Lankvelt wrote:
>
>> hi all,
>>
>> in the process of upgrading to wicket 6, I have to do some wicket ajax
>> calls from custom javascript callbacks.  The AbstractDefaultAjaxBehavior
>> seems to provide a bunch of tools to help me out.  But I cannot make sense
>> of the javadoc (& implementation) of #getCallbackFunction:
>>
>>   * Generates a javascript function that can take parameters and performs
>> an
>> AJAX call which
>>   * includes these parameters. The generated code looks like this:
>>   *
>>   * <pre>
>>   * function(param1, param2) {
>>   *    var attrs = attrsJson;
>>   *    var params = {'param1': param1, 'param2': param2};
>>   *    attrs.ep = jQuery.extend(attrs.ep, params);
>>   *    Wicket.Ajax.ajax(attrs);
>>   * }
>>   * </pre>
>>
>> But AFAIK the last line of the generated function Wicket.Ajax.ajax(attrs)
>> does not do an ajax call.
>> It just uses jQuery to register event listeners.
>>
>> So have I missed something, or is this a bug?
>>
>> thanks, Frank
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: getCallbackFunctionBody - Wicket.Ajax.ajax?

Posted by Bertrand Guay-Paquet <be...@step.polymtl.ca>.
Hi,

I use the javascript generated by getCallbackFunction just fine. Here's 
an actual function used as an onclick callback:

function (event) {
var attrs = {"u":"./103?1-1.IBehaviorListener.0-","i":"veil"};
var params = {'tourAction': "1"};
attrs.ep = params;
Wicket.Ajax.ajax(attrs);
}

The java code that generated it is :
         // Collect the extra parameters
         CallbackParameter[] parameters = new CallbackParameter[2];
         parameters[0] = CallbackParameter.context("event");
         parameters[1] = CallbackParameter.resolved("tourAction", "1");

         // Generate callback function
         CharSequence callbackFunction = getCallbackFunction(parameters);

This definitely does an ajax call. I haven't looked closely at the 
Wicket.Ajax.ajax() code, but it works fine.

Bertrand

On 19/07/2013 9:58 AM, Frank van Lankvelt wrote:
> hi all,
>
> in the process of upgrading to wicket 6, I have to do some wicket ajax
> calls from custom javascript callbacks.  The AbstractDefaultAjaxBehavior
> seems to provide a bunch of tools to help me out.  But I cannot make sense
> of the javadoc (& implementation) of #getCallbackFunction:
>
>   * Generates a javascript function that can take parameters and performs an
> AJAX call which
>   * includes these parameters. The generated code looks like this:
>   *
>   * <pre>
>   * function(param1, param2) {
>   *    var attrs = attrsJson;
>   *    var params = {'param1': param1, 'param2': param2};
>   *    attrs.ep = jQuery.extend(attrs.ep, params);
>   *    Wicket.Ajax.ajax(attrs);
>   * }
>   * </pre>
>
> But AFAIK the last line of the generated function Wicket.Ajax.ajax(attrs)
> does not do an ajax call.
> It just uses jQuery to register event listeners.
>
> So have I missed something, or is this a bug?
>
> thanks, Frank
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org