You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Marios Skounakis <ms...@gmail.com> on 2013/07/26 00:40:34 UTC

Passing parameters from java code to global ajax call listeners

Hi all,

I am subscribing to the global ajax call listeners to show and hide a veil
during ajax calls. The veil is displayed during all ajax calls. I want a
way for some components / ajax behaviors to opt our from the veil.

What I'm doing now is adding an extra parameter to the ajaxAttributes and I
am checking for it in the beforeSend listener as shown in the code below.

Is there a better way to handle this?

-- setup

Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
jqXHR, settings ) {
       showBusysign(jqXHR)
        });
   Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
jqXHR, textStatus) {
       hideBusysign()
        });

-- showing the veil:
function showBusysign(jqXHR) {
     if(typeof jqXHR.ep != 'undefined') {
         for (i=0; i<jqXHR.ep.length; i++) {if (jqXHR.ep[i].name =
'noveil') {return;}};
     }
    // go ahead and show the veil

-- java code:
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.getExtraParameters().put("noveil", "1");
            }


Thanks in advance,
Marios

Re: Passing parameters from java code to global ajax call listeners

Posted by Marios Skounakis <ms...@gmail.com>.
Ah, I now realized "data()" is a jquery feature. Now I get it.

Thanks!


On Sat, Jul 27, 2013 at 7:11 AM, Martin Grigorov <mg...@apache.org>wrote:

> or #onComponentTag()
> there is also AbstractDefaultAjaxBehavior#configureJson() (or something
> similar. I have no access to the code now)
> the idea is to mark the component/attributes somehow
> On Jul 27, 2013 12:04 AM, "Marios Skounakis" <ms...@gmail.com> wrote:
>
> > Martin,
> >
> > Thanks for your answer. I'm not sure I understand though. What does mean
> > "mark any component with data-no-veil attribute"? Use an attribute
> appender
> > to do something? If yes what? Where is this "feature" documented?
> >
> > Thanks
> > Marios
> >
> >
> > On Fri, Jul 26, 2013 at 10:21 AM, Martin Grigorov <mgrigorov@apache.org
> > >wrote:
> >
> > > Hi,
> > >
> > > You may mark any component with data-no-veil attribute.
> > > Later you can check with: if ($(attrs.c).data("no-veil") !== null)
> {...}
> > >
> > >
> > > On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis <ms...@gmail.com>
> > > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I am subscribing to the global ajax call listeners to show and hide a
> > > veil
> > > > during ajax calls. The veil is displayed during all ajax calls. I
> want
> > a
> > > > way for some components / ajax behaviors to opt our from the veil.
> > > >
> > > > What I'm doing now is adding an extra parameter to the ajaxAttributes
> > > and I
> > > > am checking for it in the beforeSend listener as shown in the code
> > below.
> > > >
> > > > Is there a better way to handle this?
> > > >
> > > > -- setup
> > > >
> > > > Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> > > > jqXHR, settings ) {
> > > >        showBusysign(jqXHR)
> > > >         });
> > > >    Wicket.Event.subscribe('/ajax/call/complete', function(
> attributes,
> > > > jqXHR, textStatus) {
> > > >        hideBusysign()
> > > >         });
> > > >
> > > > -- showing the veil:
> > > > function showBusysign(jqXHR) {
> > > >      if(typeof jqXHR.ep != 'undefined') {
> > > >          for (i=0; i<jqXHR.ep.length; i++) {if (jqXHR.ep[i].name =
> > > > 'noveil') {return;}};
> > > >      }
> > > >     // go ahead and show the veil
> > > >
> > > > -- java code:
> > > > @Override
> > > > protected void updateAjaxAttributes(AjaxRequestAttributes
> attributes) {
> > > >                 super.updateAjaxAttributes(attributes);
> > > >                 attributes.getExtraParameters().put("noveil", "1");
> > > >             }
> > > >
> > > >
> > > > Thanks in advance,
> > > > Marios
> > > >
> > >
> >
>

Re: Passing parameters from java code to global ajax call listeners

Posted by Martin Grigorov <mg...@apache.org>.
or #onComponentTag()
there is also AbstractDefaultAjaxBehavior#configureJson() (or something
similar. I have no access to the code now)
the idea is to mark the component/attributes somehow
On Jul 27, 2013 12:04 AM, "Marios Skounakis" <ms...@gmail.com> wrote:

> Martin,
>
> Thanks for your answer. I'm not sure I understand though. What does mean
> "mark any component with data-no-veil attribute"? Use an attribute appender
> to do something? If yes what? Where is this "feature" documented?
>
> Thanks
> Marios
>
>
> On Fri, Jul 26, 2013 at 10:21 AM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
>
> > Hi,
> >
> > You may mark any component with data-no-veil attribute.
> > Later you can check with: if ($(attrs.c).data("no-veil") !== null) {...}
> >
> >
> > On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis <ms...@gmail.com>
> > wrote:
> >
> > > Hi all,
> > >
> > > I am subscribing to the global ajax call listeners to show and hide a
> > veil
> > > during ajax calls. The veil is displayed during all ajax calls. I want
> a
> > > way for some components / ajax behaviors to opt our from the veil.
> > >
> > > What I'm doing now is adding an extra parameter to the ajaxAttributes
> > and I
> > > am checking for it in the beforeSend listener as shown in the code
> below.
> > >
> > > Is there a better way to handle this?
> > >
> > > -- setup
> > >
> > > Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> > > jqXHR, settings ) {
> > >        showBusysign(jqXHR)
> > >         });
> > >    Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
> > > jqXHR, textStatus) {
> > >        hideBusysign()
> > >         });
> > >
> > > -- showing the veil:
> > > function showBusysign(jqXHR) {
> > >      if(typeof jqXHR.ep != 'undefined') {
> > >          for (i=0; i<jqXHR.ep.length; i++) {if (jqXHR.ep[i].name =
> > > 'noveil') {return;}};
> > >      }
> > >     // go ahead and show the veil
> > >
> > > -- java code:
> > > @Override
> > > protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
> > >                 super.updateAjaxAttributes(attributes);
> > >                 attributes.getExtraParameters().put("noveil", "1");
> > >             }
> > >
> > >
> > > Thanks in advance,
> > > Marios
> > >
> >
>

Re: Passing parameters from java code to global ajax call listeners

Posted by Marios Skounakis <ms...@gmail.com>.
Martin,

Thanks for your answer. I'm not sure I understand though. What does mean
"mark any component with data-no-veil attribute"? Use an attribute appender
to do something? If yes what? Where is this "feature" documented?

Thanks
Marios


On Fri, Jul 26, 2013 at 10:21 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> You may mark any component with data-no-veil attribute.
> Later you can check with: if ($(attrs.c).data("no-veil") !== null) {...}
>
>
> On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis <ms...@gmail.com>
> wrote:
>
> > Hi all,
> >
> > I am subscribing to the global ajax call listeners to show and hide a
> veil
> > during ajax calls. The veil is displayed during all ajax calls. I want a
> > way for some components / ajax behaviors to opt our from the veil.
> >
> > What I'm doing now is adding an extra parameter to the ajaxAttributes
> and I
> > am checking for it in the beforeSend listener as shown in the code below.
> >
> > Is there a better way to handle this?
> >
> > -- setup
> >
> > Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> > jqXHR, settings ) {
> >        showBusysign(jqXHR)
> >         });
> >    Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
> > jqXHR, textStatus) {
> >        hideBusysign()
> >         });
> >
> > -- showing the veil:
> > function showBusysign(jqXHR) {
> >      if(typeof jqXHR.ep != 'undefined') {
> >          for (i=0; i<jqXHR.ep.length; i++) {if (jqXHR.ep[i].name =
> > 'noveil') {return;}};
> >      }
> >     // go ahead and show the veil
> >
> > -- java code:
> > @Override
> > protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
> >                 super.updateAjaxAttributes(attributes);
> >                 attributes.getExtraParameters().put("noveil", "1");
> >             }
> >
> >
> > Thanks in advance,
> > Marios
> >
>

Re: Passing parameters from java code to global ajax call listeners

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

You may mark any component with data-no-veil attribute.
Later you can check with: if ($(attrs.c).data("no-veil") !== null) {...}


On Fri, Jul 26, 2013 at 1:40 AM, Marios Skounakis <ms...@gmail.com> wrote:

> Hi all,
>
> I am subscribing to the global ajax call listeners to show and hide a veil
> during ajax calls. The veil is displayed during all ajax calls. I want a
> way for some components / ajax behaviors to opt our from the veil.
>
> What I'm doing now is adding an extra parameter to the ajaxAttributes and I
> am checking for it in the beforeSend listener as shown in the code below.
>
> Is there a better way to handle this?
>
> -- setup
>
> Wicket.Event.subscribe('/ajax/call/beforeSend', function( attributes,
> jqXHR, settings ) {
>        showBusysign(jqXHR)
>         });
>    Wicket.Event.subscribe('/ajax/call/complete', function( attributes,
> jqXHR, textStatus) {
>        hideBusysign()
>         });
>
> -- showing the veil:
> function showBusysign(jqXHR) {
>      if(typeof jqXHR.ep != 'undefined') {
>          for (i=0; i<jqXHR.ep.length; i++) {if (jqXHR.ep[i].name =
> 'noveil') {return;}};
>      }
>     // go ahead and show the veil
>
> -- java code:
> @Override
> protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
>                 super.updateAjaxAttributes(attributes);
>                 attributes.getExtraParameters().put("noveil", "1");
>             }
>
>
> Thanks in advance,
> Marios
>