You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Andrew Robinson <an...@gmail.com> on 2006/04/01 01:59:29 UTC

Extensions filter and Ajax

I am using AjaxAnywhere and Myfaces 1.1.1 and am having a problem with
Tomahawk components with AJAX.

AjaxAnywhere updates content within spans:

<span class="aazone.X">content to update</span>

Tomahawk 1.1.1 components dynamically add JavaScript and CSS style
sheets to the page's <HEAD, <head <BODY or <body tags.

The problem:
1) Render page with <t:tree2 rendered set to false
2) User clicks on an AJAX'd link
3) Page re-renders with <t:tree2 rendered set to true (due to
action/actionListener)
4) Head is not updated with new tomahawk items.

This is really a problem for me as the Tomahawk controls either don't
work or work/look really badly without those items in the head tag.
AjaxAnywhere uses a static function to find zones to render, so I have
no avenue to extend it and would rather not hack up the source.
Tomahawk's code is pretty convaluted and it does not look easy to
change where it puts the LINK & SCRIPT tags.

It doesn't look like it is possible to force tomahawk controls to
always output their JavaScript and/or CSS regardless of if they are
rendered or not as the renderer is the one that is adding those items.

Anyone have a workaround to this problem that doesn't involve the
modification of the open source (Will resort to that last)?

I suppose I could manually use the add resource when I render my page,
but that may be a bit risky. I have debated using XSLT in a filter to
"move" content around but don't want that performance overhead. I
would rather not buffer the output again as the MyFaces extension is
already buffering the response.

Thanks,
Andrew

Re: Extensions filter and Ajax

Posted by Volker Weber <us...@weber-oldenburg.de>.
Hi Andrew,

for tobago i have implemented some javascript code to enable adding of
link and script tags to the html/head after loading accordant commands
via ajax, search for 'ScriptLoader' and 'ensureStyleFiles' in
http://tinyurl.com/kcdzd.

You can look on http://tobago.atanion.net/tobago-example-demo/ how to
use it.

Regards,
  Volker




Andrew Robinson wrote:
> I'm still looking for a solution, and getting to the point where I
> need this fixed, so would appreciate any advice. I have tried:
> 
> Manually calling the Add resource's add javascript to header on the 2
> tree2 js files but I am still getting JavaScript errors. I would be
> great if the renderers could not use the head for outputting
> javascript. Instead, perhaps always adding it inline when the first
> component of that type is rendered? I know it may not be as clean in
> terms of HTML, but it works and also guarantees that the JavaScript
> will be included. Basically in the renderer:
> 
> if request map does not contain key, then
>   add on-time javascript
>   add key to request map
> end if
> 
> At this point a workaround for MyFaces1.1.1 would be enough for right
> now. I am having issues with the tabbed panel and the tree2
> components.
> 
> To add to my original post, I cannot have the CSS LINK elements added
> to the HEAD only when the rendered is set to true. I need to make sure
> that these LINK and SCRIPT tags are always added. This way, if I
> change the rendered state of a component and re-load its HTML using
> AJAX, the CSS and JavaScript will be correctly applied. Even if I get
> around the JavaScript issue, CSS will still be broken in the current
> situation as it doesn't seem like browsers like having CSS LINK files
> being dynamically added to the page on an AJAX response (perhaps just
> a limitation on AjaxAnywhere?).
> 
> So basically, how can I add all the resources for tabbed panel and
> Tree2 for my pages that MIGHT need them later, but not necessarily on
> initial page creation?
> 
> Thanks,
> Andrew
> 
> FYI - I am not using Tobago so am not aware of what it may be doing
> that could help me out.
> 
> On 4/2/06, Martin Marinschek <ma...@gmail.com> wrote:
> 
>>Tobago has something in place to solve this problem, I think.
>>
>>Maybe we could port the solution over to tomahawk?
>>
>>regards,
>>
>>Martin
>>
>>On 4/1/06, Andrew Robinson <an...@gmail.com> wrote:
>>
>>>I am using AjaxAnywhere and Myfaces 1.1.1 and am having a problem with
>>>Tomahawk components with AJAX.
>>>
>>>AjaxAnywhere updates content within spans:
>>>
>>><span class="aazone.X">content to update</span>
>>>
>>>Tomahawk 1.1.1 components dynamically add JavaScript and CSS style
>>>sheets to the page's <HEAD, <head <BODY or <body tags.
>>>
>>>The problem:
>>>1) Render page with <t:tree2 rendered set to false
>>>2) User clicks on an AJAX'd link
>>>3) Page re-renders with <t:tree2 rendered set to true (due to
>>>action/actionListener)
>>>4) Head is not updated with new tomahawk items.
>>>
>>>This is really a problem for me as the Tomahawk controls either don't
>>>work or work/look really badly without those items in the head tag.
>>>AjaxAnywhere uses a static function to find zones to render, so I have
>>>no avenue to extend it and would rather not hack up the source.
>>>Tomahawk's code is pretty convaluted and it does not look easy to
>>>change where it puts the LINK & SCRIPT tags.
>>>
>>>It doesn't look like it is possible to force tomahawk controls to
>>>always output their JavaScript and/or CSS regardless of if they are
>>>rendered or not as the renderer is the one that is adding those items.
>>>
>>>Anyone have a workaround to this problem that doesn't involve the
>>>modification of the open source (Will resort to that last)?
>>>
>>>I suppose I could manually use the add resource when I render my page,
>>>but that may be a bit risky. I have debated using XSLT in a filter to
>>>"move" content around but don't want that performance overhead. I
>>>would rather not buffer the output again as the MyFaces extension is
>>>already buffering the response.
>>>
>>>Thanks,
>>>Andrew
>>>
>>
>>
>>--
>>
>>http://www.irian.at
>>
>>Your JSF powerhouse -
>>JSF Consulting, Development and
>>Courses in English and German
>>
>>Professional Support for Apache MyFaces
>>
> 
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Re: Extensions filter and Ajax

Posted by Martin Marinschek <ma...@gmail.com>.
There has been a change in ExtensionFilter handling where you can
optionally set inline javascript resource handling.

The problem is that all CSS has to be in the head, if not, it's not valid HTML.

regards,

Martin

On 4/5/06, Andrew Robinson <an...@gmail.com> wrote:
> I'm still looking for a solution, and getting to the point where I
> need this fixed, so would appreciate any advice. I have tried:
>
> Manually calling the Add resource's add javascript to header on the 2
> tree2 js files but I am still getting JavaScript errors. I would be
> great if the renderers could not use the head for outputting
> javascript. Instead, perhaps always adding it inline when the first
> component of that type is rendered? I know it may not be as clean in
> terms of HTML, but it works and also guarantees that the JavaScript
> will be included. Basically in the renderer:
>
> if request map does not contain key, then
>   add on-time javascript
>   add key to request map
> end if
>
> At this point a workaround for MyFaces1.1.1 would be enough for right
> now. I am having issues with the tabbed panel and the tree2
> components.
>
> To add to my original post, I cannot have the CSS LINK elements added
> to the HEAD only when the rendered is set to true. I need to make sure
> that these LINK and SCRIPT tags are always added. This way, if I
> change the rendered state of a component and re-load its HTML using
> AJAX, the CSS and JavaScript will be correctly applied. Even if I get
> around the JavaScript issue, CSS will still be broken in the current
> situation as it doesn't seem like browsers like having CSS LINK files
> being dynamically added to the page on an AJAX response (perhaps just
> a limitation on AjaxAnywhere?).
>
> So basically, how can I add all the resources for tabbed panel and
> Tree2 for my pages that MIGHT need them later, but not necessarily on
> initial page creation?
>
> Thanks,
> Andrew
>
> FYI - I am not using Tobago so am not aware of what it may be doing
> that could help me out.
>
> On 4/2/06, Martin Marinschek <ma...@gmail.com> wrote:
> > Tobago has something in place to solve this problem, I think.
> >
> > Maybe we could port the solution over to tomahawk?
> >
> > regards,
> >
> > Martin
> >
> > On 4/1/06, Andrew Robinson <an...@gmail.com> wrote:
> > > I am using AjaxAnywhere and Myfaces 1.1.1 and am having a problem with
> > > Tomahawk components with AJAX.
> > >
> > > AjaxAnywhere updates content within spans:
> > >
> > > <span class="aazone.X">content to update</span>
> > >
> > > Tomahawk 1.1.1 components dynamically add JavaScript and CSS style
> > > sheets to the page's <HEAD, <head <BODY or <body tags.
> > >
> > > The problem:
> > > 1) Render page with <t:tree2 rendered set to false
> > > 2) User clicks on an AJAX'd link
> > > 3) Page re-renders with <t:tree2 rendered set to true (due to
> > > action/actionListener)
> > > 4) Head is not updated with new tomahawk items.
> > >
> > > This is really a problem for me as the Tomahawk controls either don't
> > > work or work/look really badly without those items in the head tag.
> > > AjaxAnywhere uses a static function to find zones to render, so I have
> > > no avenue to extend it and would rather not hack up the source.
> > > Tomahawk's code is pretty convaluted and it does not look easy to
> > > change where it puts the LINK & SCRIPT tags.
> > >
> > > It doesn't look like it is possible to force tomahawk controls to
> > > always output their JavaScript and/or CSS regardless of if they are
> > > rendered or not as the renderer is the one that is adding those items.
> > >
> > > Anyone have a workaround to this problem that doesn't involve the
> > > modification of the open source (Will resort to that last)?
> > >
> > > I suppose I could manually use the add resource when I render my page,
> > > but that may be a bit risky. I have debated using XSLT in a filter to
> > > "move" content around but don't want that performance overhead. I
> > > would rather not buffer the output again as the MyFaces extension is
> > > already buffering the response.
> > >
> > > Thanks,
> > > Andrew
> > >
> >
> >
> > --
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Extensions filter and Ajax

Posted by Andrew Robinson <an...@gmail.com>.
I'm still looking for a solution, and getting to the point where I
need this fixed, so would appreciate any advice. I have tried:

Manually calling the Add resource's add javascript to header on the 2
tree2 js files but I am still getting JavaScript errors. I would be
great if the renderers could not use the head for outputting
javascript. Instead, perhaps always adding it inline when the first
component of that type is rendered? I know it may not be as clean in
terms of HTML, but it works and also guarantees that the JavaScript
will be included. Basically in the renderer:

if request map does not contain key, then
  add on-time javascript
  add key to request map
end if

At this point a workaround for MyFaces1.1.1 would be enough for right
now. I am having issues with the tabbed panel and the tree2
components.

To add to my original post, I cannot have the CSS LINK elements added
to the HEAD only when the rendered is set to true. I need to make sure
that these LINK and SCRIPT tags are always added. This way, if I
change the rendered state of a component and re-load its HTML using
AJAX, the CSS and JavaScript will be correctly applied. Even if I get
around the JavaScript issue, CSS will still be broken in the current
situation as it doesn't seem like browsers like having CSS LINK files
being dynamically added to the page on an AJAX response (perhaps just
a limitation on AjaxAnywhere?).

So basically, how can I add all the resources for tabbed panel and
Tree2 for my pages that MIGHT need them later, but not necessarily on
initial page creation?

Thanks,
Andrew

FYI - I am not using Tobago so am not aware of what it may be doing
that could help me out.

On 4/2/06, Martin Marinschek <ma...@gmail.com> wrote:
> Tobago has something in place to solve this problem, I think.
>
> Maybe we could port the solution over to tomahawk?
>
> regards,
>
> Martin
>
> On 4/1/06, Andrew Robinson <an...@gmail.com> wrote:
> > I am using AjaxAnywhere and Myfaces 1.1.1 and am having a problem with
> > Tomahawk components with AJAX.
> >
> > AjaxAnywhere updates content within spans:
> >
> > <span class="aazone.X">content to update</span>
> >
> > Tomahawk 1.1.1 components dynamically add JavaScript and CSS style
> > sheets to the page's <HEAD, <head <BODY or <body tags.
> >
> > The problem:
> > 1) Render page with <t:tree2 rendered set to false
> > 2) User clicks on an AJAX'd link
> > 3) Page re-renders with <t:tree2 rendered set to true (due to
> > action/actionListener)
> > 4) Head is not updated with new tomahawk items.
> >
> > This is really a problem for me as the Tomahawk controls either don't
> > work or work/look really badly without those items in the head tag.
> > AjaxAnywhere uses a static function to find zones to render, so I have
> > no avenue to extend it and would rather not hack up the source.
> > Tomahawk's code is pretty convaluted and it does not look easy to
> > change where it puts the LINK & SCRIPT tags.
> >
> > It doesn't look like it is possible to force tomahawk controls to
> > always output their JavaScript and/or CSS regardless of if they are
> > rendered or not as the renderer is the one that is adding those items.
> >
> > Anyone have a workaround to this problem that doesn't involve the
> > modification of the open source (Will resort to that last)?
> >
> > I suppose I could manually use the add resource when I render my page,
> > but that may be a bit risky. I have debated using XSLT in a filter to
> > "move" content around but don't want that performance overhead. I
> > would rather not buffer the output again as the MyFaces extension is
> > already buffering the response.
> >
> > Thanks,
> > Andrew
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>

Re: Extensions filter and Ajax

Posted by Martin Marinschek <ma...@gmail.com>.
Tobago has something in place to solve this problem, I think.

Maybe we could port the solution over to tomahawk?

regards,

Martin

On 4/1/06, Andrew Robinson <an...@gmail.com> wrote:
> I am using AjaxAnywhere and Myfaces 1.1.1 and am having a problem with
> Tomahawk components with AJAX.
>
> AjaxAnywhere updates content within spans:
>
> <span class="aazone.X">content to update</span>
>
> Tomahawk 1.1.1 components dynamically add JavaScript and CSS style
> sheets to the page's <HEAD, <head <BODY or <body tags.
>
> The problem:
> 1) Render page with <t:tree2 rendered set to false
> 2) User clicks on an AJAX'd link
> 3) Page re-renders with <t:tree2 rendered set to true (due to
> action/actionListener)
> 4) Head is not updated with new tomahawk items.
>
> This is really a problem for me as the Tomahawk controls either don't
> work or work/look really badly without those items in the head tag.
> AjaxAnywhere uses a static function to find zones to render, so I have
> no avenue to extend it and would rather not hack up the source.
> Tomahawk's code is pretty convaluted and it does not look easy to
> change where it puts the LINK & SCRIPT tags.
>
> It doesn't look like it is possible to force tomahawk controls to
> always output their JavaScript and/or CSS regardless of if they are
> rendered or not as the renderer is the one that is adding those items.
>
> Anyone have a workaround to this problem that doesn't involve the
> modification of the open source (Will resort to that last)?
>
> I suppose I could manually use the add resource when I render my page,
> but that may be a bit risky. I have debated using XSLT in a filter to
> "move" content around but don't want that performance overhead. I
> would rather not buffer the output again as the MyFaces extension is
> already buffering the response.
>
> Thanks,
> Andrew
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces