You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michel Goldstein <mi...@gmail.com> on 2006/01/08 22:45:58 UTC

AddResource issue

Hi,

I have been trying to figure out why none of my calls to
AddResource.addJavaScriptAtPosition(...,HEADER_BEGIN,...) are working.
There is no error in the logs, but simpley the <SCRIPT/> tag does not
appear on the generated html header.

I've done a lot of different tests and my latest bare-bones test is
the following:

1) I've deployed directly the myfaces-example-simple.war built from
the repositiory to my Tomcat server and it worked on a simple example
(tree2.jsf)
2) I've copied over to my project the jsp and the data bean
(TreeBacker.java), make the addition of this bean to my faces-config
file and it didn't work. No error messages, and no <SCRIPT/>

After my tests, I have two theories (that could be both wrong): I have
a configuration problem or a library conflict. I did remove most of
the libraries and tried to make sure that I understood all the
configuration differeces between the two projects, but it still didn't
work.

Does anybody know what could be going on here? Which package is
responsible for taking the attribute maps that are set in the
AddResource to generate the html response? Is there any configuration
in this package that could be causing this problem?

Thank you,
Michel

Re: AddResource issue

Posted by Simon Kitching <sk...@obsidium.com>.
Simon Kitching wrote:
> Michel Goldstein wrote:
>> Hi,
>>
>> I have been trying to figure out why none of my calls to
>> AddResource.addJavaScriptAtPosition(...,HEADER_BEGIN,...) are working.
>> There is no error in the logs, but simpley the <SCRIPT/> tag does not
>> appear on the generated html header.
>>
>> I've done a lot of different tests and my latest bare-bones test is
>> the following:
>>
>> 1) I've deployed directly the myfaces-example-simple.war built from
>> the repositiory to my Tomcat server and it worked on a simple example
>> (tree2.jsf)
>> 2) I've copied over to my project the jsp and the data bean
>> (TreeBacker.java), make the addition of this bean to my faces-config
>> file and it didn't work. No error messages, and no <SCRIPT/>
>>
>> After my tests, I have two theories (that could be both wrong): I have
>> a configuration problem or a library conflict. I did remove most of
>> the libraries and tried to make sure that I understood all the
>> configuration differeces between the two projects, but it still didn't
>> work.
>>
>> Does anybody know what could be going on here? Which package is
>> responsible for taking the attribute maps that are set in the
>> AddResource to generate the html response? Is there any configuration
>> in this package that could be causing this problem?
> 
> The code that processes queued resources and actually modifies the 
> generated page to include them is the ExtensionsFilter. If you don't 
> have this filter mapped for "*.jsf" then that would explain your problem.
> 
>   <filter-mapping>
>     <filter-name>extensionsFilter</filter-name>
>     <url-pattern>*.jsf</url-pattern>
>   </filter-mapping>
> 

And of course..
   <filter>
     <filter-name>extensionsFilter</filter-name>
     <filter-class>
        org.apache.myfaces.component.html.util.ExtensionsFilter
     </filter-class>
   </filter>


Regards,

Simon

Re: AddResource issue

Posted by Mike Kienenberger <mk...@gmail.com>.
You can find improved extensions filter mappings on this page:

http://myfaces.apache.org/tomahawk/extensionsFilter.html

It clears up a lot of the confusion regarding what needs to be done and why.

On 1/8/06, Michel Goldstein <mi...@gmail.com> wrote:
> Simon and Greeta,
>
> That's exactly my problem. I had changed the servlet mapping to
> *.faces, but left the extension filter to *.jsf. As I was calling the
> tree2.faces, it was not calling the filter. I have cross-added the
> extensions and now everything is working!
>
> Thank you!
>
> Michel
>
> On 1/8/06, gramani@intellicare.com <gr...@intellicare.com> wrote:
> >
> > Simon Kitching <sk...@obsidium.com> wrote on 01/08/2006 04:57:59 PM:
> >
> >  >
> >  > The code that processes queued resources and actually modifies the
> >  > generated page to include them is the ExtensionsFilter. If you don't
> >  > have this filter mapped for "*.jsf" then that would explain your problem.
> >  >
> >  >    <filter-mapping>
> >  >      <filter-name>extensionsFilter</filter-name>
> >  >      <url-pattern>*.jsf</url-pattern>
> >  >    </filter-mapping>
> >  >
> >
> > Simon, shouldn't there be entries for url-patterns *.faces as well as for
> > /faces/*?
> >
> >  > Regards,
> >  >
> >  > Simon
> >
> > Regards,
> > Geeta
> >
>

Re: AddResource issue

Posted by Michel Goldstein <mi...@gmail.com>.
Simon and Greeta,

That's exactly my problem. I had changed the servlet mapping to
*.faces, but left the extension filter to *.jsf. As I was calling the
tree2.faces, it was not calling the filter. I have cross-added the
extensions and now everything is working!

Thank you!

Michel

On 1/8/06, gramani@intellicare.com <gr...@intellicare.com> wrote:
>
> Simon Kitching <sk...@obsidium.com> wrote on 01/08/2006 04:57:59 PM:
>
>  >
>  > The code that processes queued resources and actually modifies the
>  > generated page to include them is the ExtensionsFilter. If you don't
>  > have this filter mapped for "*.jsf" then that would explain your problem.
>  >
>  >    <filter-mapping>
>  >      <filter-name>extensionsFilter</filter-name>
>  >      <url-pattern>*.jsf</url-pattern>
>  >    </filter-mapping>
>  >
>
> Simon, shouldn't there be entries for url-patterns *.faces as well as for
> /faces/*?
>
>  > Regards,
>  >
>  > Simon
>
> Regards,
> Geeta
>

Re: AddResource issue

Posted by Simon Kitching <sk...@obsidium.com>.
gramani@intellicare.com wrote:
> 
> Simon Kitching <sk...@obsidium.com> wrote on 01/08/2006 04:57:59 PM:
> 
>  >
>  > The code that processes queued resources and actually modifies the
>  > generated page to include them is the ExtensionsFilter. If you don't
>  > have this filter mapped for "*.jsf" then that would explain your problem.
>  >
>  >    <filter-mapping>
>  >      <filter-name>extensionsFilter</filter-name>
>  >      <url-pattern>*.jsf</url-pattern>
>  >    </filter-mapping>
>  >
> 
> Simon, shouldn't there be entries for url-patterns *.faces as well as 
> for /faces/*?

That depends. URLs of form "/faces/myFacesExtensionResource/*" are 
generated by the AddResource class only when the resource referenced is 
stored within a jarfile in the classpath.

So adding
   <filter-mapping>
     <filter-name>extensionsFilter</filter-name>
     <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
   </filter-mapping>
is necessary if you are using any tomahawk custom components that serve 
resources (javascript etc) from within the jarfile. And necessary if 
you're using
   AddResource.addJavaScriptAtLocation
to point back at a resource within a jarfile in your webapp.

But it's not necessary if you just want to use method
   AddResource.addJavaScriptAtLocation
to insert a reference to a file held within your own webapp that is 
*not* in a jar.

Regards,

Simon


Re: AddResource issue

Posted by gr...@intellicare.com.
Simon Kitching <sk...@obsidium.com> wrote on 01/08/2006 04:57:59 PM:

> 
> The code that processes queued resources and actually modifies the 
> generated page to include them is the ExtensionsFilter. If you don't 
> have this filter mapped for "*.jsf" then that would explain your 
problem.
> 
>    <filter-mapping>
>      <filter-name>extensionsFilter</filter-name>
>      <url-pattern>*.jsf</url-pattern>
>    </filter-mapping>
> 

Simon, shouldn't there be entries for url-patterns *.faces as well as for 
/faces/*?

> Regards,
> 
> Simon

Regards,
Geeta

Re: AddResource issue

Posted by Simon Kitching <sk...@obsidium.com>.
Michel Goldstein wrote:
> Hi,
> 
> I have been trying to figure out why none of my calls to
> AddResource.addJavaScriptAtPosition(...,HEADER_BEGIN,...) are working.
> There is no error in the logs, but simpley the <SCRIPT/> tag does not
> appear on the generated html header.
> 
> I've done a lot of different tests and my latest bare-bones test is
> the following:
> 
> 1) I've deployed directly the myfaces-example-simple.war built from
> the repositiory to my Tomcat server and it worked on a simple example
> (tree2.jsf)
> 2) I've copied over to my project the jsp and the data bean
> (TreeBacker.java), make the addition of this bean to my faces-config
> file and it didn't work. No error messages, and no <SCRIPT/>
> 
> After my tests, I have two theories (that could be both wrong): I have
> a configuration problem or a library conflict. I did remove most of
> the libraries and tried to make sure that I understood all the
> configuration differeces between the two projects, but it still didn't
> work.
> 
> Does anybody know what could be going on here? Which package is
> responsible for taking the attribute maps that are set in the
> AddResource to generate the html response? Is there any configuration
> in this package that could be causing this problem?

The code that processes queued resources and actually modifies the 
generated page to include them is the ExtensionsFilter. If you don't 
have this filter mapped for "*.jsf" then that would explain your problem.

   <filter-mapping>
     <filter-name>extensionsFilter</filter-name>
     <url-pattern>*.jsf</url-pattern>
   </filter-mapping>

Regards,

Simon