Download
Foundation

Appendix: Example Configuration

General Information

This page gives a detailed example configuration for Ext-Scripting for installation details please visit thesetup guide.

Simple Configuration

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


    <description>MyProject web.xml</description>

    <!-- ======================================================================================
            Plugin Init Parameter
            First Step to enable Ext-Scripting
         ====================================================================================== -->
    <context-param>
        <description>
            Initializes the plugins for our scripting support
        </description>
        <param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name>
        <param-value>org.apache.myfaces.extensions.scripting.servlet.StartupServletContextPluginChainLoader</param-value>
    </context-param>

    <!-- ======================================================================================
            Scripting Filter
            Second step to enable Ext-Scripting
         ====================================================================================== -->
    <filter>
        <filter-name>scriptingFilter</filter-name>
        <filter-class>org.apache.myfaces.extensions.scripting.servlet.ScriptingServletFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>scriptingFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>


    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

</web-app>
        

Full Configuration

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


    <description>MyProject web.xml</description>

    <!-- ======================================================================================
            Plugin Init Parameter
            First Step to enable Ext-Scripting
         ====================================================================================== -->

    <context-param>
        <description>
            Initializes the plugins for our groovy handlers
        </description>
        <param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name>
        <param-value>org.apache.myfaces.extensions.scripting.servlet.StartupServletContextPluginChainLoader</param-value>
    </context-param>


    <!-- ======================================================================================
            Scripting Filter
            Second step to enable Ext-Scripting
         ====================================================================================== -->
    <context-param>
        <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
            of the deployment dir
        </description>
        <param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name>
        <param-value>
            /Users/werpu2/development/workspace/extensions-scripting3/examples/myfaces20-example/src/main/webapp/WEB-INF/groovy
        </param-value>
    </context-param>

    <!-- ======================================================================================
            Optional Loader Paths for Java Source Files
         ====================================================================================== -->
    <context-param>
        <description>Additional comma separated loader paths to allow direct editing on the sources directory instead
            of the deployment dir
        </description>
        <param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name>
        <param-value>
            /Users/werpu2/development/workspace/extensions-scripting3/examples/myfaces20-example/src/main/webapp/WEB-INF/java
        </param-value>
    </context-param>

    <!-- ======================================================================================
            Optional Loader Paths for Groovy Source Files
         ====================================================================================== -->
    <context-param>
        <description>resource paths for our custom JSF2 resource resolver</description>
        <param-name>org.apache.myfaces.extensions.scripting.resources.LOADER_PATHS</param-name>
        <param-value>
            /Users/werpu2/development/workspace/extensions-scripting3/examples/myfaces20-example/src/main/webapp
        </param-value>
    </context-param>

    <!-- ======================================================================================
            Optional: Tell Facelets to load the resources from your source dir
         ====================================================================================== -->
    <context-param>
        <description>a redirecting Facelet resource resolver which allows to pick up templates and resources from our
            source dir
        </description>
        <param-name>facelets.RESOURCE_RESOLVER</param-name>
        <param-value>org.apache.myfaces.extensions.scripting.facelet.ReroutingResourceResolver</param-value>
    </context-param>

    <!-- ======================================================================================
            Optional: Whitelist of root packages where your sources should come from
         ====================================================================================== -->
    <context-param>
        <description>a comma separated whitelist of root packages which are compiled those and nothing else
            will be compiled during all compile stages, all other files stay permanently as they are
        </description>
        <param-name>org.apache.myfaces.extensions.scripting.PGK_WHITELIST</param-name>
        <param-value>org.apache.myfaces.groovyloader.blog,org.apache.myfaces.javaloader.blog</param-value>
    </context-param>

    <!-- ======================================================================================
            Optional Additional Classpath
         ====================================================================================== -->
    <context-param>
        <description>
            Additional Classpaths which will be added to the compilers classpath
        </description>
        <param-name>org.apache.myfaces.extensions.scripting.PGK_ADDITIONAL_CLASSPATH</param-name>
        <param-value>/usr/lib/java/myjar.jar,/usr/lib/java/myjar2.jar</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <filter>
        <filter-name>scriptingFilter</filter-name>
        <filter-class>org.apache.myfaces.extensions.scripting.servlet.ScriptingServletFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>scriptingFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    <!-- Listener, to allow Jetty serving MyFaces apps -->
    <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>



</web-app>