You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nino martinez wael <ni...@gmail.com> on 2010/11/23 12:13:58 UTC

Determine if request are ajax?

Hi

I have a page which are ajax enabled, on first rendering (non ajax) it
should render some css. On subsequent renderings(ajax) it should only render
if new css has been added.

So I need to figure out if the the current request are a "full non ajax
refresh"  or "ajax", so how's that done? I thought that calling
AjaxRequestTarget.get would give an indication or maybe the request or the
requestcycle.. But havent found a way yet.

regards Nino

Re: Determine if request are ajax?

Posted by nino martinez wael <ni...@gmail.com>.
no did not work, gave me a working ajaxrequesttarget..

2010/11/23 Ernesto Reinaldo Barreiro <re...@gmail.com>

> AFAIK AjaxRequestTarget.get() != null <=> AJAX request. Isn't it true?
>
> Ernesto
>
> On Tue, Nov 23, 2010 at 12:13 PM, nino martinez wael
> <ni...@gmail.com> wrote:
> > Hi
> >
> > I have a page which are ajax enabled, on first rendering (non ajax) it
> > should render some css. On subsequent renderings(ajax) it should only
> render
> > if new css has been added.
> >
> > So I need to figure out if the the current request are a "full non ajax
> > refresh"  or "ajax", so how's that done? I thought that calling
> > AjaxRequestTarget.get would give an indication or maybe the request or
> the
> > requestcycle.. But havent found a way yet.
> >
> > regards Nino
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Determine if request are ajax?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
AFAIK AjaxRequestTarget.get() != null <=> AJAX request. Isn't it true?

Ernesto

On Tue, Nov 23, 2010 at 12:13 PM, nino martinez wael
<ni...@gmail.com> wrote:
> Hi
>
> I have a page which are ajax enabled, on first rendering (non ajax) it
> should render some css. On subsequent renderings(ajax) it should only render
> if new css has been added.
>
> So I need to figure out if the the current request are a "full non ajax
> refresh"  or "ajax", so how's that done? I thought that calling
> AjaxRequestTarget.get would give an indication or maybe the request or the
> requestcycle.. But havent found a way yet.
>
> regards Nino
>

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


Re: Determine if request are ajax?

Posted by nino martinez wael <ni...@gmail.com>.
right on the spot, thanks!

2010/11/23 Major Péter <ma...@sch.bme.hu>

> and in 1.5 you can use:
> ((WebRequest) RequestCycle.get().getRequest()).isAjax();
>
> Regards,
> Peter
>
> 2010-11-23 12:36 keltezéssel, nino martinez wael írta:
>
>  Argh my bad.. I thought it would give an exception and not just null..
>> Thanks for the help.
>>
>> 2010/11/23 Ernesto Reinaldo Barreiro<re...@gmail.com>
>>
>>  Exactly what AjaxRequestTarget.get() does:-)
>>>
>>> public static AjaxRequestTarget get()
>>>        {
>>>                final RequestCycle requestCycle = RequestCycle.get();
>>>                if (requestCycle != null)
>>>                {
>>>                        if (requestCycle.getRequestTarget() instanceof
>>> AjaxRequestTarget)
>>>                        {
>>>                                return
>>> (AjaxRequestTarget)requestCycle.getRequestTarget();
>>>                        }
>>>                }
>>>                return null;
>>>        }
>>>
>>> Ernesto
>>>
>>> On Tue, Nov 23, 2010 at 12:19 PM, Vitaly Tsaplin
>>> <vi...@gmail.com>  wrote:
>>>
>>>>   Sorry, I was a part of my code :)
>>>> RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget
>>>>
>>>> On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
>>>> <vi...@gmail.com>  wrote:
>>>>
>>>>>    AjaxUtils.isAjaxRequest ()
>>>>>
>>>>> On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
>>>>> <ni...@gmail.com>  wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I have a page which are ajax enabled, on first rendering (non ajax) it
>>>>>> should render some css. On subsequent renderings(ajax) it should only
>>>>>>
>>>>> render
>>>
>>>> if new css has been added.
>>>>>>
>>>>>> So I need to figure out if the the current request are a "full non
>>>>>> ajax
>>>>>> refresh"  or "ajax", so how's that done? I thought that calling
>>>>>> AjaxRequestTarget.get would give an indication or maybe the request or
>>>>>>
>>>>> the
>>>
>>>> requestcycle.. But havent found a way yet.
>>>>>>
>>>>>> regards Nino
>>>>>>
>>>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Determine if request are ajax?

Posted by Major Péter <ma...@sch.bme.hu>.
and in 1.5 you can use:
((WebRequest) RequestCycle.get().getRequest()).isAjax();

Regards,
Peter

2010-11-23 12:36 keltezéssel, nino martinez wael írta:
> Argh my bad.. I thought it would give an exception and not just null..
> Thanks for the help.
>
> 2010/11/23 Ernesto Reinaldo Barreiro<re...@gmail.com>
>
>> Exactly what AjaxRequestTarget.get() does:-)
>>
>> public static AjaxRequestTarget get()
>>         {
>>                 final RequestCycle requestCycle = RequestCycle.get();
>>                 if (requestCycle != null)
>>                 {
>>                         if (requestCycle.getRequestTarget() instanceof
>> AjaxRequestTarget)
>>                         {
>>                                 return
>> (AjaxRequestTarget)requestCycle.getRequestTarget();
>>                         }
>>                 }
>>                 return null;
>>         }
>>
>> Ernesto
>>
>> On Tue, Nov 23, 2010 at 12:19 PM, Vitaly Tsaplin
>> <vi...@gmail.com>  wrote:
>>>    Sorry, I was a part of my code :)
>>> RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget
>>>
>>> On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
>>> <vi...@gmail.com>  wrote:
>>>>     AjaxUtils.isAjaxRequest ()
>>>>
>>>> On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
>>>> <ni...@gmail.com>  wrote:
>>>>> Hi
>>>>>
>>>>> I have a page which are ajax enabled, on first rendering (non ajax) it
>>>>> should render some css. On subsequent renderings(ajax) it should only
>> render
>>>>> if new css has been added.
>>>>>
>>>>> So I need to figure out if the the current request are a "full non ajax
>>>>> refresh"  or "ajax", so how's that done? I thought that calling
>>>>> AjaxRequestTarget.get would give an indication or maybe the request or
>> the
>>>>> requestcycle.. But havent found a way yet.
>>>>>
>>>>> regards Nino

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


Re: Determine if request are ajax?

Posted by nino martinez wael <ni...@gmail.com>.
Argh my bad.. I thought it would give an exception and not just null..
Thanks for the help.

2010/11/23 Ernesto Reinaldo Barreiro <re...@gmail.com>

> Exactly what AjaxRequestTarget.get() does:-)
>
> public static AjaxRequestTarget get()
>        {
>                final RequestCycle requestCycle = RequestCycle.get();
>                if (requestCycle != null)
>                {
>                        if (requestCycle.getRequestTarget() instanceof
> AjaxRequestTarget)
>                        {
>                                return
> (AjaxRequestTarget)requestCycle.getRequestTarget();
>                        }
>                }
>                return null;
>        }
>
> Ernesto
>
> On Tue, Nov 23, 2010 at 12:19 PM, Vitaly Tsaplin
> <vi...@gmail.com> wrote:
> >   Sorry, I was a part of my code :)
> > RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget
> >
> > On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
> > <vi...@gmail.com> wrote:
> >>    AjaxUtils.isAjaxRequest ()
> >>
> >> On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
> >> <ni...@gmail.com> wrote:
> >>> Hi
> >>>
> >>> I have a page which are ajax enabled, on first rendering (non ajax) it
> >>> should render some css. On subsequent renderings(ajax) it should only
> render
> >>> if new css has been added.
> >>>
> >>> So I need to figure out if the the current request are a "full non ajax
> >>> refresh"  or "ajax", so how's that done? I thought that calling
> >>> AjaxRequestTarget.get would give an indication or maybe the request or
> the
> >>> requestcycle.. But havent found a way yet.
> >>>
> >>> regards Nino
> >>>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Determine if request are ajax?

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Exactly what AjaxRequestTarget.get() does:-)

public static AjaxRequestTarget get()
	{
		final RequestCycle requestCycle = RequestCycle.get();
		if (requestCycle != null)
		{
			if (requestCycle.getRequestTarget() instanceof AjaxRequestTarget)
			{
				return (AjaxRequestTarget)requestCycle.getRequestTarget();
			}
		}
		return null;
	}

Ernesto

On Tue, Nov 23, 2010 at 12:19 PM, Vitaly Tsaplin
<vi...@gmail.com> wrote:
>   Sorry, I was a part of my code :)
> RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget
>
> On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
> <vi...@gmail.com> wrote:
>>    AjaxUtils.isAjaxRequest ()
>>
>> On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
>> <ni...@gmail.com> wrote:
>>> Hi
>>>
>>> I have a page which are ajax enabled, on first rendering (non ajax) it
>>> should render some css. On subsequent renderings(ajax) it should only render
>>> if new css has been added.
>>>
>>> So I need to figure out if the the current request are a "full non ajax
>>> refresh"  or "ajax", so how's that done? I thought that calling
>>> AjaxRequestTarget.get would give an indication or maybe the request or the
>>> requestcycle.. But havent found a way yet.
>>>
>>> regards Nino
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Determine if request are ajax?

Posted by nino martinez wael <ni...@gmail.com>.
Ahh will try it.

2010/11/23 Vitaly Tsaplin <vi...@gmail.com>

>   Sorry, I was a part of my code :)
> RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget
>
> On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
> <vi...@gmail.com> wrote:
> >    AjaxUtils.isAjaxRequest ()
> >
> > On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
> > <ni...@gmail.com> wrote:
> >> Hi
> >>
> >> I have a page which are ajax enabled, on first rendering (non ajax) it
> >> should render some css. On subsequent renderings(ajax) it should only
> render
> >> if new css has been added.
> >>
> >> So I need to figure out if the the current request are a "full non ajax
> >> refresh"  or "ajax", so how's that done? I thought that calling
> >> AjaxRequestTarget.get would give an indication or maybe the request or
> the
> >> requestcycle.. But havent found a way yet.
> >>
> >> regards Nino
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Determine if request are ajax?

Posted by Vitaly Tsaplin <vi...@gmail.com>.
   Sorry, I was a part of my code :)
RequestCycle.get ().getRequestTarget () instanceof AjaxRequestTarget

On Tue, Nov 23, 2010 at 2:18 PM, Vitaly Tsaplin
<vi...@gmail.com> wrote:
>    AjaxUtils.isAjaxRequest ()
>
> On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
> <ni...@gmail.com> wrote:
>> Hi
>>
>> I have a page which are ajax enabled, on first rendering (non ajax) it
>> should render some css. On subsequent renderings(ajax) it should only render
>> if new css has been added.
>>
>> So I need to figure out if the the current request are a "full non ajax
>> refresh"  or "ajax", so how's that done? I thought that calling
>> AjaxRequestTarget.get would give an indication or maybe the request or the
>> requestcycle.. But havent found a way yet.
>>
>> regards Nino
>>
>

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


Re: Determine if request are ajax?

Posted by Vitaly Tsaplin <vi...@gmail.com>.
    AjaxUtils.isAjaxRequest ()

On Tue, Nov 23, 2010 at 2:13 PM, nino martinez wael
<ni...@gmail.com> wrote:
> Hi
>
> I have a page which are ajax enabled, on first rendering (non ajax) it
> should render some css. On subsequent renderings(ajax) it should only render
> if new css has been added.
>
> So I need to figure out if the the current request are a "full non ajax
> refresh"  or "ajax", so how's that done? I thought that calling
> AjaxRequestTarget.get would give an indication or maybe the request or the
> requestcycle.. But havent found a way yet.
>
> regards Nino
>

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