Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

FAQ Category:

Facelets uses a plugable resource resolver (where the resource is the view template). You simply provide your own implementation of the Facelets ResourceResolver interface and have it look in any classloader to locate the resource.

Here's an example implementation that extends the default implementation to load templates from the classpath that don't begin with a forward slash, otherwise delegating to the default resolver:

import com.sun.facelets.impl.DefaultResourceResolver;
import com.sun.facelets.impl.ResourceResolver;
 
public class CustomResourceResolver extends DefaultResourceResolver implements ResourceResolver
{
    @Override
    public URL resolveUrl(String resource)
    {
        URL resourceUrl = super.resolveUrl(resource);
        if (resourceUrl == null)
        {
            if (resource.startsWith("/"))
            {
                resource = resource.substring(1);
            }
            resourceUrl = Thread.currentThread().getContextClassLoader().getResource(resource);
        }
        return resourceUrl;
    }
}

Then register the custom resolver with Facelets by defining a special context parameter in web.xml.

<context-param>
	<param-name>facelets.RESOURCE_RESOLVER</param-name>
	<param-value>CustomResourceResolver</param-value>
</context-param>

You can of course invent your own resolver strategy. You might even decide to fetch the resource from a remote URL or database.

A full example of creating a shared Facelets JAR file can be found in this post courtesy of OCPsoft.

1 comment:
 
09. Mar 2012, 00:43 America/New_York | Link

Faceless uses a plug able imagination resolver (where the resourcefulness is the compass model. You only give your own effort of the Faceless Resource Resolver port and person it countenance in any class loader to find the ingeniousness. pass4sure 642-902 pass4sure 640-864 pass4sure 640-816