You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Apple Grew <ap...@gmail.com> on 2010/04/22 05:40:28 UTC

Strip header contributors from Ajax response.

I have a component which contributes Js headers. This component is also
rendered by AjaxRequestTarget. The problem is that when rendering ajax
response the Js codes too are getting rendered. These Js codes were already
contributed when this component first rendered (in non-Ajax mode).

To fix this what I initially did was that in the onBeforeRender method of
the component I was checking if the response NOT isAjax then add the header
contributors, else, remove them. This was working fine, but problem is if I
want to implement this is other components I would have to copy n paste the
codes. So I decided to implement a behavior. I added all the header
contributors to that behavior and it was supposed to do the job of adding n
removing the header contributors. But we can't modify hierarchy from
beforeRender of behavior so I am now stuck. Furthermore, this approach is
not capable of removing JS contributed by super calsses of the componenet.

Please suggest.

Thanks and regards,
Apple Grew
my blog @ http://blog.applegrew.com/

Re: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
Hi Igor,

It is not that duplicates items are getting rendered. What I want is that
the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax mode
the Js code should be stripped out. As these Js codes are not executed when
in Ajax response so it doesn't make sense to render them there. This
unnecessarily bloats the response.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> wicket will filter duplicate contributions for you and even though
> they are rendered they are not executed. if you are writing out
> javascript directly you can set a string id which uniquely identifies
> the contribution and wicket will also filter by that.
>
> -igor
>
> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
> > I have a component which contributes Js headers. This component is also
> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
> > response the Js codes too are getting rendered. These Js codes were
> already
> > contributed when this component first rendered (in non-Ajax mode).
> >
> > To fix this what I initially did was that in the onBeforeRender method of
> > the component I was checking if the response NOT isAjax then add the
> header
> > contributors, else, remove them. This was working fine, but problem is if
> I
> > want to implement this is other components I would have to copy n paste
> the
> > codes. So I decided to implement a behavior. I added all the header
> > contributors to that behavior and it was supposed to do the job of adding
> n
> > removing the header contributors. But we can't modify hierarchy from
> > beforeRender of behavior so I am now stuck. Furthermore, this approach is
> > not capable of removing JS contributed by super calsses of the
> componenet.
> >
> > Please suggest.
> >
> > Thanks and regards,
> > Apple Grew
> > my blog @ http://blog.applegrew.com/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
ohk... will check.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 23, 2010 at 10:08 AM, Igor Vaynberg <ig...@gmail.com>wrote:

> you use iheadercontributor to write out the url to the resourse, which
> i think will point to the javascriptpackageresource.
>
> -igor
>
> On Thu, Apr 22, 2010 at 9:29 PM, Apple Grew <ap...@gmail.com> wrote:
> > That's a good point. :)
> >
> > BTW if i implement my own IHeaderContributor how will take advantage of
> > wicket's js code stripper and compressor provided by
> > JavascriptPackageResource?
> >
> > Regards,
> > Apple Grew
> > my blog @ http://blog.applegrew.com/
> >
> >
> > On Fri, Apr 23, 2010 at 9:46 AM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
> >
> >> if you have a million hit site you can probably afford the hosting :)
> >>
> >> -igor
> >>
> >> On Thu, Apr 22, 2010 at 8:16 PM, Tim L Casey <tc...@cataphora.com>
> wrote:
> >> >
> >> >
> >> > In terms of hosting it is measurable.  Each byte of request for a
> million
> >> > hit site is 10Mbit of line cost.
> >> >
> >> > That being said most latency is about connections and not amount of
> data.
> >> > At least in terms of speed up I would look first at reducing things
> like
> >> > frames, then resources, then size.
> >> >
> >> > Inlined ajax, yeah /shrug with the caveat for hosting solutions.
> >> >
> >> > tim
> >> >
> >> > -----Original Message-----
> >> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> >> > Sent: Thursday, April 22, 2010 8:08 PM
> >> > To: users@wicket.apache.org
> >> > Subject: Re: Strip header contributors from Ajax response.
> >> >
> >> > amd this bloating has caused a noticeable slowdown in your site's
> >> > response times? how much latency is it adding to the response?
> >> >
> >> > that said, you can always output it using iheaderresponsecontributor
> >> > and add an check if you are inside ajax or not using request.isajax()
> >> >
> >> > -igor
> >> >
> >> > On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com>
> wrote:
> >> >> Hi Igor,
> >> >>
> >> >> It is not that duplicates items are getting rendered. What I want is
> >> that
> >> >> the Js should be rendered ONLY when rendering in non-Ajax mode. In
> Ajax
> >> > mode
> >> >> the Js code should be stripped out. As these Js codes are not
> executed
> >> > when
> >> >> in Ajax response so it doesn't make sense to render them there. This
> >> >> unnecessarily bloats the response.
> >> >>
> >> >> Regards,
> >> >> Apple Grew
> >> >> my blog @ http://blog.applegrew.com/
> >> >>
> >> >>
> >> >> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg
> >> > <ig...@gmail.com>wrote:
> >> >>
> >> >>> wicket will filter duplicate contributions for you and even though
> >> >>> they are rendered they are not executed. if you are writing out
> >> >>> javascript directly you can set a string id which uniquely
> identifies
> >> >>> the contribution and wicket will also filter by that.
> >> >>>
> >> >>> -igor
> >> >>>
> >> >>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com>
> >> wrote:
> >> >>> > I have a component which contributes Js headers. This component is
> >> also
> >> >>> > rendered by AjaxRequestTarget. The problem is that when rendering
> >> ajax
> >> >>> > response the Js codes too are getting rendered. These Js codes
> were
> >> >>> already
> >> >>> > contributed when this component first rendered (in non-Ajax mode).
> >> >>> >
> >> >>> > To fix this what I initially did was that in the onBeforeRender
> >> method
> >> > of
> >> >>> > the component I was checking if the response NOT isAjax then add
> the
> >> >>> header
> >> >>> > contributors, else, remove them. This was working fine, but
> problem
> >> is
> >> > if
> >> >>> I
> >> >>> > want to implement this is other components I would have to copy n
> >> paste
> >> >>> the
> >> >>> > codes. So I decided to implement a behavior. I added all the
> header
> >> >>> > contributors to that behavior and it was supposed to do the job of
> >> > adding
> >> >>> n
> >> >>> > removing the header contributors. But we can't modify hierarchy
> from
> >> >>> > beforeRender of behavior so I am now stuck. Furthermore, this
> >> approach
> >> > is
> >> >>> > not capable of removing JS contributed by super calsses of the
> >> >>> componenet.
> >> >>> >
> >> >>> > Please suggest.
> >> >>> >
> >> >>> > Thanks and regards,
> >> >>> > Apple Grew
> >> >>> > my blog @ http://blog.applegrew.com/
> >> >>> >
> >> >>>
> >> >>>
> ---------------------------------------------------------------------
> >> >>> 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
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > 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
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Strip header contributors from Ajax response.

Posted by Igor Vaynberg <ig...@gmail.com>.
you use iheadercontributor to write out the url to the resourse, which
i think will point to the javascriptpackageresource.

-igor

On Thu, Apr 22, 2010 at 9:29 PM, Apple Grew <ap...@gmail.com> wrote:
> That's a good point. :)
>
> BTW if i implement my own IHeaderContributor how will take advantage of
> wicket's js code stripper and compressor provided by
> JavascriptPackageResource?
>
> Regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>
>
> On Fri, Apr 23, 2010 at 9:46 AM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> if you have a million hit site you can probably afford the hosting :)
>>
>> -igor
>>
>> On Thu, Apr 22, 2010 at 8:16 PM, Tim L Casey <tc...@cataphora.com> wrote:
>> >
>> >
>> > In terms of hosting it is measurable.  Each byte of request for a million
>> > hit site is 10Mbit of line cost.
>> >
>> > That being said most latency is about connections and not amount of data.
>> > At least in terms of speed up I would look first at reducing things like
>> > frames, then resources, then size.
>> >
>> > Inlined ajax, yeah /shrug with the caveat for hosting solutions.
>> >
>> > tim
>> >
>> > -----Original Message-----
>> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> > Sent: Thursday, April 22, 2010 8:08 PM
>> > To: users@wicket.apache.org
>> > Subject: Re: Strip header contributors from Ajax response.
>> >
>> > amd this bloating has caused a noticeable slowdown in your site's
>> > response times? how much latency is it adding to the response?
>> >
>> > that said, you can always output it using iheaderresponsecontributor
>> > and add an check if you are inside ajax or not using request.isajax()
>> >
>> > -igor
>> >
>> > On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
>> >> Hi Igor,
>> >>
>> >> It is not that duplicates items are getting rendered. What I want is
>> that
>> >> the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
>> > mode
>> >> the Js code should be stripped out. As these Js codes are not executed
>> > when
>> >> in Ajax response so it doesn't make sense to render them there. This
>> >> unnecessarily bloats the response.
>> >>
>> >> Regards,
>> >> Apple Grew
>> >> my blog @ http://blog.applegrew.com/
>> >>
>> >>
>> >> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg
>> > <ig...@gmail.com>wrote:
>> >>
>> >>> wicket will filter duplicate contributions for you and even though
>> >>> they are rendered they are not executed. if you are writing out
>> >>> javascript directly you can set a string id which uniquely identifies
>> >>> the contribution and wicket will also filter by that.
>> >>>
>> >>> -igor
>> >>>
>> >>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com>
>> wrote:
>> >>> > I have a component which contributes Js headers. This component is
>> also
>> >>> > rendered by AjaxRequestTarget. The problem is that when rendering
>> ajax
>> >>> > response the Js codes too are getting rendered. These Js codes were
>> >>> already
>> >>> > contributed when this component first rendered (in non-Ajax mode).
>> >>> >
>> >>> > To fix this what I initially did was that in the onBeforeRender
>> method
>> > of
>> >>> > the component I was checking if the response NOT isAjax then add the
>> >>> header
>> >>> > contributors, else, remove them. This was working fine, but problem
>> is
>> > if
>> >>> I
>> >>> > want to implement this is other components I would have to copy n
>> paste
>> >>> the
>> >>> > codes. So I decided to implement a behavior. I added all the header
>> >>> > contributors to that behavior and it was supposed to do the job of
>> > adding
>> >>> n
>> >>> > removing the header contributors. But we can't modify hierarchy from
>> >>> > beforeRender of behavior so I am now stuck. Furthermore, this
>> approach
>> > is
>> >>> > not capable of removing JS contributed by super calsses of the
>> >>> componenet.
>> >>> >
>> >>> > Please suggest.
>> >>> >
>> >>> > Thanks and regards,
>> >>> > Apple Grew
>> >>> > my blog @ http://blog.applegrew.com/
>> >>> >
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> 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
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>
>

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


Re: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
That's a good point. :)

BTW if i implement my own IHeaderContributor how will take advantage of
wicket's js code stripper and compressor provided by
JavascriptPackageResource?

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 23, 2010 at 9:46 AM, Igor Vaynberg <ig...@gmail.com>wrote:

> if you have a million hit site you can probably afford the hosting :)
>
> -igor
>
> On Thu, Apr 22, 2010 at 8:16 PM, Tim L Casey <tc...@cataphora.com> wrote:
> >
> >
> > In terms of hosting it is measurable.  Each byte of request for a million
> > hit site is 10Mbit of line cost.
> >
> > That being said most latency is about connections and not amount of data.
> > At least in terms of speed up I would look first at reducing things like
> > frames, then resources, then size.
> >
> > Inlined ajax, yeah /shrug with the caveat for hosting solutions.
> >
> > tim
> >
> > -----Original Message-----
> > From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> > Sent: Thursday, April 22, 2010 8:08 PM
> > To: users@wicket.apache.org
> > Subject: Re: Strip header contributors from Ajax response.
> >
> > amd this bloating has caused a noticeable slowdown in your site's
> > response times? how much latency is it adding to the response?
> >
> > that said, you can always output it using iheaderresponsecontributor
> > and add an check if you are inside ajax or not using request.isajax()
> >
> > -igor
> >
> > On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
> >> Hi Igor,
> >>
> >> It is not that duplicates items are getting rendered. What I want is
> that
> >> the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
> > mode
> >> the Js code should be stripped out. As these Js codes are not executed
> > when
> >> in Ajax response so it doesn't make sense to render them there. This
> >> unnecessarily bloats the response.
> >>
> >> Regards,
> >> Apple Grew
> >> my blog @ http://blog.applegrew.com/
> >>
> >>
> >> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg
> > <ig...@gmail.com>wrote:
> >>
> >>> wicket will filter duplicate contributions for you and even though
> >>> they are rendered they are not executed. if you are writing out
> >>> javascript directly you can set a string id which uniquely identifies
> >>> the contribution and wicket will also filter by that.
> >>>
> >>> -igor
> >>>
> >>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com>
> wrote:
> >>> > I have a component which contributes Js headers. This component is
> also
> >>> > rendered by AjaxRequestTarget. The problem is that when rendering
> ajax
> >>> > response the Js codes too are getting rendered. These Js codes were
> >>> already
> >>> > contributed when this component first rendered (in non-Ajax mode).
> >>> >
> >>> > To fix this what I initially did was that in the onBeforeRender
> method
> > of
> >>> > the component I was checking if the response NOT isAjax then add the
> >>> header
> >>> > contributors, else, remove them. This was working fine, but problem
> is
> > if
> >>> I
> >>> > want to implement this is other components I would have to copy n
> paste
> >>> the
> >>> > codes. So I decided to implement a behavior. I added all the header
> >>> > contributors to that behavior and it was supposed to do the job of
> > adding
> >>> n
> >>> > removing the header contributors. But we can't modify hierarchy from
> >>> > beforeRender of behavior so I am now stuck. Furthermore, this
> approach
> > is
> >>> > not capable of removing JS contributed by super calsses of the
> >>> componenet.
> >>> >
> >>> > Please suggest.
> >>> >
> >>> > Thanks and regards,
> >>> > Apple Grew
> >>> > my blog @ http://blog.applegrew.com/
> >>> >
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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
> >
> >
> > ---------------------------------------------------------------------
> > 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: Strip header contributors from Ajax response.

Posted by Igor Vaynberg <ig...@gmail.com>.
if you have a million hit site you can probably afford the hosting :)

-igor

On Thu, Apr 22, 2010 at 8:16 PM, Tim L Casey <tc...@cataphora.com> wrote:
>
>
> In terms of hosting it is measurable.  Each byte of request for a million
> hit site is 10Mbit of line cost.
>
> That being said most latency is about connections and not amount of data.
> At least in terms of speed up I would look first at reducing things like
> frames, then resources, then size.
>
> Inlined ajax, yeah /shrug with the caveat for hosting solutions.
>
> tim
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Sent: Thursday, April 22, 2010 8:08 PM
> To: users@wicket.apache.org
> Subject: Re: Strip header contributors from Ajax response.
>
> amd this bloating has caused a noticeable slowdown in your site's
> response times? how much latency is it adding to the response?
>
> that said, you can always output it using iheaderresponsecontributor
> and add an check if you are inside ajax or not using request.isajax()
>
> -igor
>
> On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
>> Hi Igor,
>>
>> It is not that duplicates items are getting rendered. What I want is that
>> the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
> mode
>> the Js code should be stripped out. As these Js codes are not executed
> when
>> in Ajax response so it doesn't make sense to render them there. This
>> unnecessarily bloats the response.
>>
>> Regards,
>> Apple Grew
>> my blog @ http://blog.applegrew.com/
>>
>>
>> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg
> <ig...@gmail.com>wrote:
>>
>>> wicket will filter duplicate contributions for you and even though
>>> they are rendered they are not executed. if you are writing out
>>> javascript directly you can set a string id which uniquely identifies
>>> the contribution and wicket will also filter by that.
>>>
>>> -igor
>>>
>>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
>>> > I have a component which contributes Js headers. This component is also
>>> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
>>> > response the Js codes too are getting rendered. These Js codes were
>>> already
>>> > contributed when this component first rendered (in non-Ajax mode).
>>> >
>>> > To fix this what I initially did was that in the onBeforeRender method
> of
>>> > the component I was checking if the response NOT isAjax then add the
>>> header
>>> > contributors, else, remove them. This was working fine, but problem is
> if
>>> I
>>> > want to implement this is other components I would have to copy n paste
>>> the
>>> > codes. So I decided to implement a behavior. I added all the header
>>> > contributors to that behavior and it was supposed to do the job of
> adding
>>> n
>>> > removing the header contributors. But we can't modify hierarchy from
>>> > beforeRender of behavior so I am now stuck. Furthermore, this approach
> is
>>> > not capable of removing JS contributed by super calsses of the
>>> componenet.
>>> >
>>> > Please suggest.
>>> >
>>> > Thanks and regards,
>>> > Apple Grew
>>> > my blog @ http://blog.applegrew.com/
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>
> ---------------------------------------------------------------------
> 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: Strip header contributors from Ajax response.

Posted by Tim L Casey <tc...@cataphora.com>.

In terms of hosting it is measurable.  Each byte of request for a million
hit site is 10Mbit of line cost.

That being said most latency is about connections and not amount of data.
At least in terms of speed up I would look first at reducing things like
frames, then resources, then size.

Inlined ajax, yeah /shrug with the caveat for hosting solutions.

tim

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Sent: Thursday, April 22, 2010 8:08 PM
To: users@wicket.apache.org
Subject: Re: Strip header contributors from Ajax response.

amd this bloating has caused a noticeable slowdown in your site's
response times? how much latency is it adding to the response?

that said, you can always output it using iheaderresponsecontributor
and add an check if you are inside ajax or not using request.isajax()

-igor

On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
> Hi Igor,
>
> It is not that duplicates items are getting rendered. What I want is that
> the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
mode
> the Js code should be stripped out. As these Js codes are not executed
when
> in Ajax response so it doesn't make sense to render them there. This
> unnecessarily bloats the response.
>
> Regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>
>
> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg
<ig...@gmail.com>wrote:
>
>> wicket will filter duplicate contributions for you and even though
>> they are rendered they are not executed. if you are writing out
>> javascript directly you can set a string id which uniquely identifies
>> the contribution and wicket will also filter by that.
>>
>> -igor
>>
>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
>> > I have a component which contributes Js headers. This component is also
>> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
>> > response the Js codes too are getting rendered. These Js codes were
>> already
>> > contributed when this component first rendered (in non-Ajax mode).
>> >
>> > To fix this what I initially did was that in the onBeforeRender method
of
>> > the component I was checking if the response NOT isAjax then add the
>> header
>> > contributors, else, remove them. This was working fine, but problem is
if
>> I
>> > want to implement this is other components I would have to copy n paste
>> the
>> > codes. So I decided to implement a behavior. I added all the header
>> > contributors to that behavior and it was supposed to do the job of
adding
>> n
>> > removing the header contributors. But we can't modify hierarchy from
>> > beforeRender of behavior so I am now stuck. Furthermore, this approach
is
>> > not capable of removing JS contributed by super calsses of the
>> componenet.
>> >
>> > Please suggest.
>> >
>> > Thanks and regards,
>> > Apple Grew
>> > my blog @ http://blog.applegrew.com/
>> >
>>
>> ---------------------------------------------------------------------
>> 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


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


Re: Strip header contributors from Ajax response.

Posted by Igor Vaynberg <ig...@gmail.com>.
org.apache.wicket.markup.html.IHeaderContributor

-igor

On Thu, Apr 22, 2010 at 8:35 PM, Apple Grew <ap...@gmail.com> wrote:
> @Igor
>
> I have a very tight budget so the resources are pretty limited, so I need to
> save the bandwidth wherever possible. BTW I didn't find any class -
> iheaderresponsecontributor.
>
> Regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>
>
> On Fri, Apr 23, 2010 at 8:37 AM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> amd this bloating has caused a noticeable slowdown in your site's
>> response times? how much latency is it adding to the response?
>>
>> that said, you can always output it using iheaderresponsecontributor
>> and add an check if you are inside ajax or not using request.isajax()
>>
>> -igor
>>
>> On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
>> > Hi Igor,
>> >
>> > It is not that duplicates items are getting rendered. What I want is that
>> > the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
>> mode
>> > the Js code should be stripped out. As these Js codes are not executed
>> when
>> > in Ajax response so it doesn't make sense to render them there. This
>> > unnecessarily bloats the response.
>> >
>> > Regards,
>> > Apple Grew
>> > my blog @ http://blog.applegrew.com/
>> >
>> >
>> > On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg <igor.vaynberg@gmail.com
>> >wrote:
>> >
>> >> wicket will filter duplicate contributions for you and even though
>> >> they are rendered they are not executed. if you are writing out
>> >> javascript directly you can set a string id which uniquely identifies
>> >> the contribution and wicket will also filter by that.
>> >>
>> >> -igor
>> >>
>> >> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com>
>> wrote:
>> >> > I have a component which contributes Js headers. This component is
>> also
>> >> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
>> >> > response the Js codes too are getting rendered. These Js codes were
>> >> already
>> >> > contributed when this component first rendered (in non-Ajax mode).
>> >> >
>> >> > To fix this what I initially did was that in the onBeforeRender method
>> of
>> >> > the component I was checking if the response NOT isAjax then add the
>> >> header
>> >> > contributors, else, remove them. This was working fine, but problem is
>> if
>> >> I
>> >> > want to implement this is other components I would have to copy n
>> paste
>> >> the
>> >> > codes. So I decided to implement a behavior. I added all the header
>> >> > contributors to that behavior and it was supposed to do the job of
>> adding
>> >> n
>> >> > removing the header contributors. But we can't modify hierarchy from
>> >> > beforeRender of behavior so I am now stuck. Furthermore, this approach
>> is
>> >> > not capable of removing JS contributed by super calsses of the
>> >> componenet.
>> >> >
>> >> > Please suggest.
>> >> >
>> >> > Thanks and regards,
>> >> > Apple Grew
>> >> > my blog @ http://blog.applegrew.com/
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>>
>>
>

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


Re: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
@Igor

I have a very tight budget so the resources are pretty limited, so I need to
save the bandwidth wherever possible. BTW I didn't find any class -
iheaderresponsecontributor.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 23, 2010 at 8:37 AM, Igor Vaynberg <ig...@gmail.com>wrote:

> amd this bloating has caused a noticeable slowdown in your site's
> response times? how much latency is it adding to the response?
>
> that said, you can always output it using iheaderresponsecontributor
> and add an check if you are inside ajax or not using request.isajax()
>
> -igor
>
> On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
> > Hi Igor,
> >
> > It is not that duplicates items are getting rendered. What I want is that
> > the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax
> mode
> > the Js code should be stripped out. As these Js codes are not executed
> when
> > in Ajax response so it doesn't make sense to render them there. This
> > unnecessarily bloats the response.
> >
> > Regards,
> > Apple Grew
> > my blog @ http://blog.applegrew.com/
> >
> >
> > On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
> >
> >> wicket will filter duplicate contributions for you and even though
> >> they are rendered they are not executed. if you are writing out
> >> javascript directly you can set a string id which uniquely identifies
> >> the contribution and wicket will also filter by that.
> >>
> >> -igor
> >>
> >> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com>
> wrote:
> >> > I have a component which contributes Js headers. This component is
> also
> >> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
> >> > response the Js codes too are getting rendered. These Js codes were
> >> already
> >> > contributed when this component first rendered (in non-Ajax mode).
> >> >
> >> > To fix this what I initially did was that in the onBeforeRender method
> of
> >> > the component I was checking if the response NOT isAjax then add the
> >> header
> >> > contributors, else, remove them. This was working fine, but problem is
> if
> >> I
> >> > want to implement this is other components I would have to copy n
> paste
> >> the
> >> > codes. So I decided to implement a behavior. I added all the header
> >> > contributors to that behavior and it was supposed to do the job of
> adding
> >> n
> >> > removing the header contributors. But we can't modify hierarchy from
> >> > beforeRender of behavior so I am now stuck. Furthermore, this approach
> is
> >> > not capable of removing JS contributed by super calsses of the
> >> componenet.
> >> >
> >> > Please suggest.
> >> >
> >> > Thanks and regards,
> >> > Apple Grew
> >> > my blog @ http://blog.applegrew.com/
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> 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: Strip header contributors from Ajax response.

Posted by Igor Vaynberg <ig...@gmail.com>.
amd this bloating has caused a noticeable slowdown in your site's
response times? how much latency is it adding to the response?

that said, you can always output it using iheaderresponsecontributor
and add an check if you are inside ajax or not using request.isajax()

-igor

On Thu, Apr 22, 2010 at 6:29 PM, Apple Grew <ap...@gmail.com> wrote:
> Hi Igor,
>
> It is not that duplicates items are getting rendered. What I want is that
> the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax mode
> the Js code should be stripped out. As these Js codes are not executed when
> in Ajax response so it doesn't make sense to render them there. This
> unnecessarily bloats the response.
>
> Regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>
>
> On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> wicket will filter duplicate contributions for you and even though
>> they are rendered they are not executed. if you are writing out
>> javascript directly you can set a string id which uniquely identifies
>> the contribution and wicket will also filter by that.
>>
>> -igor
>>
>> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
>> > I have a component which contributes Js headers. This component is also
>> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
>> > response the Js codes too are getting rendered. These Js codes were
>> already
>> > contributed when this component first rendered (in non-Ajax mode).
>> >
>> > To fix this what I initially did was that in the onBeforeRender method of
>> > the component I was checking if the response NOT isAjax then add the
>> header
>> > contributors, else, remove them. This was working fine, but problem is if
>> I
>> > want to implement this is other components I would have to copy n paste
>> the
>> > codes. So I decided to implement a behavior. I added all the header
>> > contributors to that behavior and it was supposed to do the job of adding
>> n
>> > removing the header contributors. But we can't modify hierarchy from
>> > beforeRender of behavior so I am now stuck. Furthermore, this approach is
>> > not capable of removing JS contributed by super calsses of the
>> componenet.
>> >
>> > Please suggest.
>> >
>> > Thanks and regards,
>> > Apple Grew
>> > my blog @ http://blog.applegrew.com/
>> >
>>
>> ---------------------------------------------------------------------
>> 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: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
Hi Igor,

It is not that duplicates items are getting rendered. What I want is that
the Js should be rendered ONLY when rendering in non-Ajax mode. In Ajax mode
the Js code should be stripped out. As these Js codes are not executed when
in Ajax response so it doesn't make sense to render them there. This
unnecessarily bloats the response.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Thu, Apr 22, 2010 at 10:50 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> wicket will filter duplicate contributions for you and even though
> they are rendered they are not executed. if you are writing out
> javascript directly you can set a string id which uniquely identifies
> the contribution and wicket will also filter by that.
>
> -igor
>
> On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
> > I have a component which contributes Js headers. This component is also
> > rendered by AjaxRequestTarget. The problem is that when rendering ajax
> > response the Js codes too are getting rendered. These Js codes were
> already
> > contributed when this component first rendered (in non-Ajax mode).
> >
> > To fix this what I initially did was that in the onBeforeRender method of
> > the component I was checking if the response NOT isAjax then add the
> header
> > contributors, else, remove them. This was working fine, but problem is if
> I
> > want to implement this is other components I would have to copy n paste
> the
> > codes. So I decided to implement a behavior. I added all the header
> > contributors to that behavior and it was supposed to do the job of adding
> n
> > removing the header contributors. But we can't modify hierarchy from
> > beforeRender of behavior so I am now stuck. Furthermore, this approach is
> > not capable of removing JS contributed by super calsses of the
> componenet.
> >
> > Please suggest.
> >
> > Thanks and regards,
> > Apple Grew
> > my blog @ http://blog.applegrew.com/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Strip header contributors from Ajax response.

Posted by Igor Vaynberg <ig...@gmail.com>.
wicket will filter duplicate contributions for you and even though
they are rendered they are not executed. if you are writing out
javascript directly you can set a string id which uniquely identifies
the contribution and wicket will also filter by that.

-igor

On Wed, Apr 21, 2010 at 8:40 PM, Apple Grew <ap...@gmail.com> wrote:
> I have a component which contributes Js headers. This component is also
> rendered by AjaxRequestTarget. The problem is that when rendering ajax
> response the Js codes too are getting rendered. These Js codes were already
> contributed when this component first rendered (in non-Ajax mode).
>
> To fix this what I initially did was that in the onBeforeRender method of
> the component I was checking if the response NOT isAjax then add the header
> contributors, else, remove them. This was working fine, but problem is if I
> want to implement this is other components I would have to copy n paste the
> codes. So I decided to implement a behavior. I added all the header
> contributors to that behavior and it was supposed to do the job of adding n
> removing the header contributors. But we can't modify hierarchy from
> beforeRender of behavior so I am now stuck. Furthermore, this approach is
> not capable of removing JS contributed by super calsses of the componenet.
>
> Please suggest.
>
> Thanks and regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>

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


Re: Strip header contributors from Ajax response.

Posted by Apple Grew <ap...@gmail.com>.
Hi All,

Thanks for all the responses. I got this solved by making my behavior extend
AbstractHeaderContributor. In its getHeaderContributors() I return the list
of headers only if response is not ajax. In case of ajax I simply return
null.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 30, 2010 at 3:44 AM, DV <da...@gmail.com> wrote:

>
> Another more complicated way seems to be using SharedResources and
> DynamicWebResources, an example of this, you can find it on
> "UploadStatusResource" class of
> wicket.extensions.ajax.markup.html.form.upload package
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Strip-header-contributors-from-Ajax-response-tp2019993p2076272.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Strip header contributors from Ajax response.

Posted by DV <da...@gmail.com>.
Another more complicated way seems to be using SharedResources and
DynamicWebResources, an example of this, you can find it on
"UploadStatusResource" class of 
wicket.extensions.ajax.markup.html.form.upload package
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Strip-header-contributors-from-Ajax-response-tp2019993p2076272.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Strip header contributors from Ajax response.

Posted by DV <da...@gmail.com>.
Good Afternoon,

I've working on this theme, and I found a solution to avoid the strip of our
resources.

On the Ajax Behavior, we put this lines:

ResourceStreamRequestTarget targetRes = new ResourceStreamRequestTarget( new
PackageResourceStream(MyScopeClass.class,"resources/myJS.js"));
targetRes.setFileName("MyJS.js");
RequestCycle.get().setRequestTarget(targetRes);


And, this way, we can still using our resources redered with the
HeadersConstriburtors


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Strip-header-contributors-from-Ajax-response-tp2019993p2076267.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Strip header contributors from Ajax response.

Posted by Pointbreak <po...@ml1.net>.
if (!AjaxRequestTarget.get())
    renderMyJavascript();

On Thu, 22 Apr 2010 09:10 +0530, "Apple Grew" <ap...@gmail.com>
wrote:
> I have a component which contributes Js headers. This component is also
> rendered by AjaxRequestTarget. The problem is that when rendering ajax
> response the Js codes too are getting rendered. These Js codes were
> already
> contributed when this component first rendered (in non-Ajax mode).
> 
> To fix this what I initially did was that in the onBeforeRender method of
> the component I was checking if the response NOT isAjax then add the
> header
> contributors, else, remove them. This was working fine, but problem is if
> I
> want to implement this is other components I would have to copy n paste
> the
> codes. So I decided to implement a behavior. I added all the header
> contributors to that behavior and it was supposed to do the job of adding
> n
> removing the header contributors. But we can't modify hierarchy from
> beforeRender of behavior so I am now stuck. Furthermore, this approach is
> not capable of removing JS contributed by super calsses of the
> componenet.
> 
> Please suggest.
> 
> Thanks and regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
> 

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