You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2007/03/02 00:23:04 UTC

AjaxRequestTarget and (Ajax)HeaderResponse..

Hi,

first why is in the current head (of 1.3)

    public void renderOnDomReadyJavascript(String javascript)
and
    public void renderOnLoadJavascript(String javascript)

not tested for if that script is already rendered?
(For both the HeaderResponse and the AjaxHeaderResponse)

all others are. (so i made that now also the case for the HR and AHR)

But why do we override those 2 methods in the AHR and not the method:

public void renderJavascript(CharSequence javascript, String id)

so that we also can add them tho the appendJavascripts list? (just as we do
with onLoad and onDom)

If we do that then we could also sync the appendJavaScript method of
AjaxRequestTArget with
the 3 (onDom,onLoad and just javascript) to test for duplicates.

Because what is really different of all the append javascript methods of ART
and render method of HR?

For example why do we have an extra ID in the HR of renderJavaScript (to
target duplicates or to say it is for this X thing)
but we don't have that in the ART append methods..

Couldn't for exampel ART be a HR (instead of having an inner class AHR?)
It is sort of the same isn't it?

johan

Re: AjaxRequestTarget and (Ajax)HeaderResponse..

Posted by Matej Knopp <ma...@knopp.sk>.
Yes, I know this is a problem. I've taken care of this, look at my 
today's commit. If you don't like it for some reason, we can discuss it 
more.

-Matej

Johan Compagner wrote:
> the problem is the i dont want duplicates in the AbstractAjaxTimerBehavior
> we have there still a problem, i do now only this in renderHead:
> 
> if (!stopped)
> {
>            response.renderOnLoadJavascript
> (getJsTimeoutCall(updateInterval));
> }
> 
> that works fine. But what if the component that does have this behavior
> isn't added
> to the ajaxrequesttarget to render component?
> 
> what i want to do is this:
> 
> protected final void respond(final AjaxRequestTarget target)
> {
>        onTimer(target);
> 
>  // add this line: target.appendJavaScript
> (getJsTimeoutCall(updateInterval));
> }
> 
> But if the component is added then that appendJavaScript does it double.
> So i can make a boolean that test if i already appended that string
> But i rather would be able to say:
> 
> response.renderOnLoadJavascript(getJsTimeoutCall(updateInterval). "XXXID");
> target.appendJavaScript(getJsTimeoutCall(updateInterval), "XXXID")
> 
> johan
> 
> 
> On 3/2/07, Matej Knopp <ma...@knopp.sk> wrote:
>>
>> Johan Compagner wrote:
>> > Hi,
>> >
>> > first why is in the current head (of 1.3)
>> >
>> >    public void renderOnDomReadyJavascript(String javascript)
>> > and
>> >    public void renderOnLoadJavascript(String javascript)
>> >
>> > not tested for if that script is already rendered?
>> > (For both the HeaderResponse and the AjaxHeaderResponse)
>>
>> Because i see no reason why it should be. But if you have, it can be
>> filtered.
>>
>> >
>> > all others are. (so i made that now also the case for the HR and AHR)
>> >
>> > But why do we override those 2 methods in the AHR and not the method:
>> >
>> > public void renderJavascript(CharSequence javascript, String id)
>> >
>> > so that we also can add them tho the appendJavascripts list? (just 
>> as we
>> do
>> > with onLoad and onDom)
>> Because we dont need to! This is already handled during ajax using ajax
>> header contribution. And it is processed when all other header-related
>> things are. Why are you trying to fix something that ain't broken?
>> >
>> > If we do that then we could also sync the appendJavaScript method of
>> > AjaxRequestTArget with
>> > the 3 (onDom,onLoad and just javascript) to test for duplicates.
>> No! What if you really want to execute the javascript multiple times?
>> You have to call appendJavascript every request manually, so you are in
>> charge of preventing duplicates.
>> >
>> > Because what is really different of all the append javascript 
>> methods of
>> > ART
>> > and render method of HR?
>> Usecase. Javascript methods on ART can be used for pre- and
>> postprocessing of document during ajax request. They have well defined
>> and _simple_ semantics.
>> >
>> > For example why do we have an extra ID in the HR of renderJavaScript 
>> (to
>> > target duplicates or to say it is for this X thing)
>> > but we don't have that in the ART append methods..
>> Because it's not needed, as the id is used for preventing duplicates.
>> And javascript methods of ART _don't_ filter duplicates. And they are
>> not supposed to do so.
>> >
>> > Couldn't for exampel ART be a HR (instead of having an inner class 
>> AHR?)
>> > It is sort of the same isn't it?
>> Nope. It's not. Header response is header response. It does renders
>> javascript snippets, links, etc. and filters duplicate contributions.
>> How is this sort of same than ART?
>>
>> I can't see anything positive on integrating ART and HR. What would be
>> the benefit? For all I can see it would just duplicate code. HC is not
>> related to ajax in anyway, except that we subclass it to "emulate" the
>> onLoad and onDomReady calls during Ajax.
>>
>> -Matej
>> >
>> > johan
>> >
>>
>>
>>
> 


Re: AjaxRequestTarget and (Ajax)HeaderResponse..

Posted by Johan Compagner <jc...@gmail.com>.
the problem is the i dont want duplicates in the AbstractAjaxTimerBehavior
we have there still a problem, i do now only this in renderHead:

if (!stopped)
{
            response.renderOnLoadJavascript
(getJsTimeoutCall(updateInterval));
}

that works fine. But what if the component that does have this behavior
isn't added
to the ajaxrequesttarget to render component?

what i want to do is this:

protected final void respond(final AjaxRequestTarget target)
{
        onTimer(target);

  // add this line: target.appendJavaScript
(getJsTimeoutCall(updateInterval));
}

But if the component is added then that appendJavaScript does it double.
So i can make a boolean that test if i already appended that string
But i rather would be able to say:

response.renderOnLoadJavascript(getJsTimeoutCall(updateInterval). "XXXID");
target.appendJavaScript(getJsTimeoutCall(updateInterval), "XXXID")

johan


On 3/2/07, Matej Knopp <ma...@knopp.sk> wrote:
>
> Johan Compagner wrote:
> > Hi,
> >
> > first why is in the current head (of 1.3)
> >
> >    public void renderOnDomReadyJavascript(String javascript)
> > and
> >    public void renderOnLoadJavascript(String javascript)
> >
> > not tested for if that script is already rendered?
> > (For both the HeaderResponse and the AjaxHeaderResponse)
>
> Because i see no reason why it should be. But if you have, it can be
> filtered.
>
> >
> > all others are. (so i made that now also the case for the HR and AHR)
> >
> > But why do we override those 2 methods in the AHR and not the method:
> >
> > public void renderJavascript(CharSequence javascript, String id)
> >
> > so that we also can add them tho the appendJavascripts list? (just as we
> do
> > with onLoad and onDom)
> Because we dont need to! This is already handled during ajax using ajax
> header contribution. And it is processed when all other header-related
> things are. Why are you trying to fix something that ain't broken?
> >
> > If we do that then we could also sync the appendJavaScript method of
> > AjaxRequestTArget with
> > the 3 (onDom,onLoad and just javascript) to test for duplicates.
> No! What if you really want to execute the javascript multiple times?
> You have to call appendJavascript every request manually, so you are in
> charge of preventing duplicates.
> >
> > Because what is really different of all the append javascript methods of
> > ART
> > and render method of HR?
> Usecase. Javascript methods on ART can be used for pre- and
> postprocessing of document during ajax request. They have well defined
> and _simple_ semantics.
> >
> > For example why do we have an extra ID in the HR of renderJavaScript (to
> > target duplicates or to say it is for this X thing)
> > but we don't have that in the ART append methods..
> Because it's not needed, as the id is used for preventing duplicates.
> And javascript methods of ART _don't_ filter duplicates. And they are
> not supposed to do so.
> >
> > Couldn't for exampel ART be a HR (instead of having an inner class AHR?)
> > It is sort of the same isn't it?
> Nope. It's not. Header response is header response. It does renders
> javascript snippets, links, etc. and filters duplicate contributions.
> How is this sort of same than ART?
>
> I can't see anything positive on integrating ART and HR. What would be
> the benefit? For all I can see it would just duplicate code. HC is not
> related to ajax in anyway, except that we subclass it to "emulate" the
> onLoad and onDomReady calls during Ajax.
>
> -Matej
> >
> > johan
> >
>
>
>

Re: AjaxRequestTarget and (Ajax)HeaderResponse..

Posted by Matej Knopp <ma...@knopp.sk>.
Johan Compagner wrote:
> Hi,
> 
> first why is in the current head (of 1.3)
> 
>    public void renderOnDomReadyJavascript(String javascript)
> and
>    public void renderOnLoadJavascript(String javascript)
> 
> not tested for if that script is already rendered?
> (For both the HeaderResponse and the AjaxHeaderResponse)

Because i see no reason why it should be. But if you have, it can be
filtered.

> 
> all others are. (so i made that now also the case for the HR and AHR)
> 
> But why do we override those 2 methods in the AHR and not the method:
> 
> public void renderJavascript(CharSequence javascript, String id)
> 
> so that we also can add them tho the appendJavascripts list? (just as we do
> with onLoad and onDom)
Because we dont need to! This is already handled during ajax using ajax
header contribution. And it is processed when all other header-related
things are. Why are you trying to fix something that ain't broken?
> 
> If we do that then we could also sync the appendJavaScript method of
> AjaxRequestTArget with
> the 3 (onDom,onLoad and just javascript) to test for duplicates.
No! What if you really want to execute the javascript multiple times?
You have to call appendJavascript every request manually, so you are in
charge of preventing duplicates.
> 
> Because what is really different of all the append javascript methods of 
> ART
> and render method of HR?
Usecase. Javascript methods on ART can be used for pre- and
postprocessing of document during ajax request. They have well defined
and _simple_ semantics.
> 
> For example why do we have an extra ID in the HR of renderJavaScript (to
> target duplicates or to say it is for this X thing)
> but we don't have that in the ART append methods..
Because it's not needed, as the id is used for preventing duplicates.
And javascript methods of ART _don't_ filter duplicates. And they are
not supposed to do so.
> 
> Couldn't for exampel ART be a HR (instead of having an inner class AHR?)
> It is sort of the same isn't it?
Nope. It's not. Header response is header response. It does renders
javascript snippets, links, etc. and filters duplicate contributions.
How is this sort of same than ART?

I can't see anything positive on integrating ART and HR. What would be
the benefit? For all I can see it would just duplicate code. HC is not
related to ajax in anyway, except that we subclass it to "emulate" the
onLoad and onDomReady calls during Ajax.

-Matej
> 
> johan
>