Checkout and Build
A manual build for beta-1 is not necessary you always can obtain the needed files via Maven(see below) or you can download them manually and have the integrated manually (also see below), however if you prefer a build from source you can follow the explanations presented here: You can download the sources of the Ext-Scripting Beta-1 from: The beta 1 tag http://svn.apache.org/repos/asf/myfaces/extensions/scripting/tags/1_0_beta_1
Make sure you have following requirements fulfilled before checking out:
- A valid Subversion client
- Java 5 or higher
- Maven 2.0.9 or higher
After checkout, a full build can be obtained from the root directory of your checkout viamvn clean install.
Once finished, a valid build is installed, which can be used further on. Additionally you can find two blueprint projects which you can use as starting points for your own projects under <checkoutDir>/examples , which can be started viamvn jetty:run-exploded.
Setup of Ext-Scripting
Requirements
Before setting up Ext-Scripting make sure following requirements are met.
- JAVA_HOME points towards a valid Java SDK (JRE is not sufficient)
- You know how to create and deploy a web application within your preferred setup (command line, ide)
Setup
While one of the aims of Ext-Scripting was to enable an easy setup, for now it was not entirely possible for now to get a plug and play configuration. Several configuration steps have to be performed.
- A valid MyFaces installation has to be present
- Ext-Scripting and its dependencies has to be added to the MyFaces installation
- The paths to the scripts have to be present (see also below)
Preparations via Apache Maven 2
The easiest way is probably to use Ext-Scripting via Apache Maven 2
(note a compile is not necessary since all needed files are hosted on the apache infrastructure)
As a prerequisite make sure you have added following entry to your pom.xml so that the appropriate jars can be loaded from our beta build repository:
<repositories>
<repository>
<id>extscript-beta-1</id>
<url>http://people.apache.org/~lu4242/extscript10beta1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
This will enable Maven to download the beta-1 build jars from the internet.
Depending on your configuration and preferred JDK version you can add following entries to your Maven pom.xml to enable Ext-Scripting
Preparing the Necessary web.xml Entries
First Step
To enable Ext-Scripting you also have to add several entries to your web.xml file.
First a context param has to be set which attaches the Ext-Scripting plugins to MyFaces
<context-param>
<description>
Enables our scripting engine support plugins
</description>
<param-name>org.apache.myfaces.FACES_INIT_PLUGINS</param-name>
<param-value>
org.apache.myfaces.scripting.servlet.StartupServletContextPluginChainLoader
</param-value>
</context-param>Second Step
Add Ext-Scriptings servlet filter to your servlet configuration
<filter>
<filter-name>scriptingFilter</filter-name>
<filter-class>org.apache.myfaces.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>The init parameter and the servlet filter MUST be set otherwise Ext-Scripting will not be enabled!
Additional Optional Steps
Ext-Scripting exposes a number configuration parameters which can be set via context parameters in your web.xml
Adjust the web.xml Root source paths
Since the goal of Ext-Scripting is to provide scriptability to a running web application, it has to know where to find the sources. For this, a default location has been chosen according to the standards set by the Mojarra Groovy Extension.
The location looks like:
<webapp>/WEB-INF/groovy
as root location for Groovy files
<webapp>/WEB-INF/java
as root location for java files.
Following image displays the default locations:
However in a normal development scenario, it is often undesirable to have the files located in a deployment location, and a pointer mechanism towards the actual source locations would be more desirable. To provide such a mechanism, Ext-Scripting allows two optional web.xml context parameters, which allow the rerouting of source locations of the supported languages!
<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.scripting.groovy.LOADER_PATHS</param-name>
<param-value>
<some project path>/src/main/webapp/WEB-INF/groovy
</param-value>
</context-param>
<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.scripting.java.LOADER_PATHS</param-name>
<param-value>
<some project path>/src/main/webapp/WEB-INF/java
</param-value>
</context-param>
- org.apache.myfaces.scripting.groovy.LOADER_PATHS can be a comma separated list of paths which point to the actual Groovy sources.
- org.apache.myfaces.scripting.java.LOADER_PATHS does the same for Java sources..