wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernesto Reinaldo Barreiro <reier...@gmail.com>
Subject Re: Ajax behavior that can be reused for multiple components
Date Tue, 08 Oct 2013 19:49:44 GMT
This link might be useful too

https://github.com/reiern70/antilia-bits/tree/master/wicket-sparelinks




On Tue, Oct 8, 2013 at 9:31 PM, Marios Skounakis <mscoon@gmail.com> wrote:

> Hi all,
>
> I want to implement an ajax behavior similar to
> AjaxFormComponentUpdatingBehavior but which can be attached only once to a
> parent container component and issue ajax calls for all contained form
> components.
>
> So what I did was extend AbstractDefaultAjaxBehavior and pretty much copy
> the logic of AjaxFormComponentUpdatingBehavior respond() except that the
> component is located via the request parameters.
>
> This worked quite ok.
>
> I had a lot of trouble with emitting the appropriate javascript. The
> behavior by default attaches to the container component and does not post
> anything useful. So I had to resort to adding custom javascript in
> renderHead().
>
> I ended up manually constructing a variable with the post parameters and
> using jQuery post() to send them to the behavior's callback url.
>
> response.render(OnDomReadyHeaderItem
>                     .forScript("$('#" + markupId + "').on('blur', '.df',
> function() {var comp = $(this).attr('name'); var data = {}; data[comp] =
> $(this).val(); data['component']=comp; data['"
>                             + WebRequest.PARAM_AJAX
>                             + "']=true; data['"
>                             + WebRequest.PARAM_AJAX_BASE_URL
>                             + "']=Wicket.Ajax.baseUrl; $.post('"
>                             + getCallbackUrl() + "', data);" + "});"));
>         }
>
> I wanted to use Wicket.Ajax calls to achieve the same effect but failed
> miserably in all attempts to use Wicket.Ajax.ajax() or Wicket.Ajax.post().
> It is my understanding that these register event handlers rather than issue
> direct calls.
>
> So, how does one use the Wicket.Ajax library to issue an ajax call with
> custom post parameters? Is there some documentation I am not aware of?
>
> Thanks
> Marios
>



-- 
Regards - Ernesto Reinaldo Barreiro

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message