You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-dev@incubator.apache.org by Böhringer Jochen <Jo...@tcc-products.de> on 2006/12/07 10:32:07 UTC

Trinidad: How does PPR replace content in the dom?

Hello,

how does PPR replace content in the dom of the page. I know that PPR uses an IFrame. But how is the data loaded into the IFrame copied into the main page?

I guess it could be realized this way:

1.) Load new HTML markup into the IFrame.
2.) Copy the new markup in the Iframe to the main Frame using .innerHtml

Am I right or is it done using another mechanism? If I'm right and I have a component whose renderer generates markup containing <script>alert('Test');</script>

This scriptlet would first be executed after loaded into the iframe. And would be executed a second time if the ppr mechanism has copied it into the main frame. Is this correct?

If yes, how can I generate a javascript in a renderer which is called after the markup is copied into the mainframe and not in the iframe? Is there a special trick I can use in a component using PPR capabilities? I would like to do it the Trinidad way, because I would like to donate my DragAndDrop component (as soon as it works) back to Trinidad.

Regards
Jochen

Re: Trinidad: How does PPR replace content in the dom?

Posted by Adam Winer <aw...@gmail.com>.
On 12/7/06, Böhringer Jochen <Jo...@tcc-products.de> wrote:
> Hello,
>
> how does PPR replace content in the dom of the page. I know that PPR uses an IFrame. But how is the data loaded into the IFrame copied into the main page?
>
> I guess it could be realized this way:
>
> 1.) Load new HTML markup into the IFrame.
> 2.) Copy the new markup in the Iframe to the main Frame using .innerHtml

Roughly speaking, yes, though it's a lot more complicated than that.

>
> Am I right or is it done using another mechanism? If I'm right and I have a component whose renderer generates markup containing <script>alert('Test');</script>
>
> This scriptlet would first be executed after loaded into the iframe. And would be executed a second time if the ppr mechanism has copied it into the main frame. Is this correct?

No, it's actually more clever than that - as long as you write out the
script element using ResponseWriter.startElement.  My memory's gotten
a little fuzy on the details - you may
also need to call writeAttribute("defer", Boolean.TRUE, null).  But,
at any rate, the script
is blocked for execution in the iframe, then executed in the main page.

When I get the chance to rewrite the code to use XMLHttp instead of an iframe,
this gets a bit easier in some ways (a bit harder in others).

-- Adam


> If yes, how can I generate a javascript in a renderer which is called after the markup is copied into the mainframe and not in the iframe? Is there a special trick I can use in a component using PPR capabilities? I would like to do it the Trinidad way, because I would like to donate my DragAndDrop component (as soon as it works) back to Trinidad.
>
> Regards
> Jochen
>

Re: Trinidad: How does PPR replace content in the dom?

Posted by Adam Winer <aw...@gmail.com>.
On 12/7/06, Böhringer Jochen <Jo...@tcc-products.de> wrote:
> Hello,
>
> how does PPR replace content in the dom of the page. I know that PPR uses an IFrame. But how is the data loaded into the IFrame copied into the main page?
>
> I guess it could be realized this way:
>
> 1.) Load new HTML markup into the IFrame.
> 2.) Copy the new markup in the Iframe to the main Frame using .innerHtml

Roughly speaking, yes, though it's a lot more complicated than that.

>
> Am I right or is it done using another mechanism? If I'm right and I have a component whose renderer generates markup containing <script>alert('Test');</script>
>
> This scriptlet would first be executed after loaded into the iframe. And would be executed a second time if the ppr mechanism has copied it into the main frame. Is this correct?

No, it's actually more clever than that - as long as you write out the
script element using ResponseWriter.startElement.  My memory's gotten
a little fuzy on the details - you may
also need to call writeAttribute("defer", Boolean.TRUE, null).  But,
at any rate, the script
is blocked for execution in the iframe, then executed in the main page.

When I get the chance to rewrite the code to use XMLHttp instead of an iframe,
this gets a bit easier in some ways (a bit harder in others).

-- Adam


> If yes, how can I generate a javascript in a renderer which is called after the markup is copied into the mainframe and not in the iframe? Is there a special trick I can use in a component using PPR capabilities? I would like to do it the Trinidad way, because I would like to donate my DragAndDrop component (as soon as it works) back to Trinidad.
>
> Regards
> Jochen
>