Some MyFaces components do more than include some HTML in the pages.
They may need additional support scripts, style sheets, images, ...
Those resources are included in the MyFaces' jar file and the Extensions Filter adds the code and URL needed to provide those resources to the generated HTML.
Some other components, like the file upload component (t:inputFileUpload), need to parse
The extensions filter handles this as well.
This design has several benefits :
- It provides a clean separation between MyFaces' components and your webapp.
- You don't have to include additional MyFaces' components-related code or resources in your pages or webapp.
- It provides flexibility so that the MyFaces' team can upgrade the components while keeping transparent backward compatibility.
- It makes it possible for complex components to use many support resources without any burden on the page developer.
- It loads only the resources useful for the rendered components.
- It handles the MyFaces' resources caching.
When a component needs a resource, it calls one of the org.apache.myfaces.component.html.util.AddResource methods
The URL for an embedded resource begins with /faces/myFacesExtensionResource so that it can be intercepted by the filter when the client needs to load the resource.
When the clients fetches the resource, the filter also decodes the URL, and serves the proper resource from the MyFaces' jar.
Alternate mapping using a url-pattern instead of a servlet-name (you still need the /faces/myFacesExtensionResource/* mapping as well):
<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages --> <filter-mapping> <filter-name>MyFacesExtensionsFilter</filter-name> <url-pattern>*.jsf</url-pattern> </filter-mapping>
See the javadoc for class ExtensionsFilter for information on the full set of configuration options for this filter.
If you just use standard JSF component, but don't use any MyFaces' extended component (beginning with t:),
then you don't need the Extensions Filter.
However, if you use some of the MyFaces' extended components like t:inputFileUpload, t:inputHtml, t:inputCalendar, ... then you most likely need to have this filter configured in your webapp.