Class ViewResourceHandler

  • All Implemented Interfaces:

    public class ViewResourceHandler
    extends DefaultResourceHandler
    This ResourceHandler basically turns any concrete non-Facelets file into a Faces view, so that you can use EL expressions and even Faces components in them. The response content type will default to Faces.getMimeType(String) which is configureable in web.xml and overrideable via <f:view contentType="...">.

    Real world examples are /sitemap.xml and /robots.txt.


    To get it to run, this handler needs be registered as follows in faces-config.xml:


    To configure the Faces view resources, a "org.omnifaces.VIEW_RESOURCE_HANDLER_URIS" context parameter has to be provided wherein the view resources are specified as a comma separated string of context-relative URIs.

    Here is an example configuration:

         <param-value>/sitemap.xml, /products/sitemap.xml, /reviews/sitemap.xml, /robots.txt</param-value>

    Wildcards in URIs are at the moment not supported.

    The OmniViewHandler will take care of rendering the view.

    Bauke Scholtz
    See Also:
    DefaultResourceHandler, OmniViewHandler
    • Field Detail


        public static final String PARAM_NAME_VIEW_RESOURCES
        The context parameter name to specify URIs to treat as Faces views.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ViewResourceHandler

        public ViewResourceHandler​(ResourceHandler wrapped)
        Creates a new instance of this view resource handler which wraps the given resource handler.
        wrapped - The resource handler to be wrapped.