Package JSF Flow in a JAR file
In the article JSF Flow example we have seen how to define a JSF Flow inside the same web application where it will eventually be used, basically by using the application's own folder structure.
In this article we will define that exact same flow but we will package it inside a JAR (library) file instead.
JSF Flow packaging in a JAR file
In order for a flow to be packaged in a JAR file it must follow some rules:
- The flow definition bust be explicitly declared in the JAR file under META-INF/faces-config.xml
- Every flow node (or view) must be declared in a directory which name is the same name of the flow, under META-INF/flows (ex: META-INF/flows/[FLOW_NAME])
With this set of rules in mind we may change the original flow definition to JAR packaging without much effort:
Note that the Order flow nodes (order*.xhtml) and the respective OrderBean are all defined in the com-byteslounge-jsf-flow project. This project will be included as a JAR file inside WEB-INF/lib directory of the web application project (com-byteslounge-jsf-war).
The Order flow will work exactly as the one we have previously defined by using the web application directory structure in JSF Flow example.
The source code is available for download at the end of this page.