You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Holloway <bi...@gmail.com> on 2007/07/26 23:09:05 UTC

Putting a component body with property expansions in the

Hi,

I need to put some javascript in the <head> that has dynamic content (JSON
strings).  That javascript also needs to be put in the head only from
certain pages, not all of them.

I can do this for *static* javascript assets via (for example)

void beginRender (MarkupWriter writer)
{
        Document doc = writer.getDocument();
        Element head = doc.find ("html/head");
        if (head == null) head = doc.find ("html").element("head");

        head.element("script", "type", "text/javascript", "src",
_assetParameter.toClientURL());
}

But my javascript needs to expand component properties.  My initial thought
is to try to use a block in a component with the properties and then try to
render that in the <head> via the dom model as above somehow, but I don't
know how to put the block in.

Bill

Re: Putting a component body with property expansions in the

Posted by Andrea Chiumenti <ki...@gmail.com>.
You can use @Shell delegate attribute.
http://tapestry.apache.org/tapestry4.1/components/general/shell.html

Ciao,
kiuma

On 7/26/07, Bill Holloway <bi...@gmail.com> wrote:
>
> Hi,
>
> I need to put some javascript in the <head> that has dynamic content (JSON
> strings).  That javascript also needs to be put in the head only from
> certain pages, not all of them.
>
> I can do this for *static* javascript assets via (for example)
>
> void beginRender (MarkupWriter writer)
> {
>         Document doc = writer.getDocument();
>         Element head = doc.find ("html/head");
>         if (head == null) head = doc.find ("html").element("head");
>
>         head.element("script", "type", "text/javascript", "src",
> _assetParameter.toClientURL());
> }
>
> But my javascript needs to expand component properties.  My initial
> thought
> is to try to use a block in a component with the properties and then try
> to
> render that in the <head> via the dom model as above somehow, but I don't
> know how to put the block in.
>
> Bill
>