By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
JSF Flex example
JSF Flex Lifecyle
The project itself will piggy back on JSF's lifecycle with one main difference being that there will exists an interlude step called buildComponentInterlude between buildComponentBegin and buildComponentChildren.
encodeBegin: buildComponentBegin buildComponentInterlude
The following image shows a brief overview of some of the steps taken during the various application modes [debugMode, simplySWF, and productionEnv].
Brief overview of JSF Flex Lifecycle
One thing to note is that buildComponentEnd II process occurs only once per application, since the existence of system resources are checked prior to creating them. Also each application is allowed various modes fit for different purposes.
- debugMode : preMxml, Mxml, and SWF files would be created in each run as well as JSON objects.
- simplySWF : Mxml which has been modified by the user exists, so create only SWF files and JSON objects [users can use this to modify the mxml file and create a swf file].
- productionEnv : SWF file already exists, so nothing to do here but create JSON objects [this is the default value to ensure that users do not run the components in either of the two other modes in an environment that is higher than dev]. One thing to note is that all directories of Webcontent/swf/* should be copied to their corresponding directory within the Workspace during the move to higher environment, since the system uses servContext.getRealPath(new String()) as the root directory of preMxml, Mxml, and swf directory and Tomcat for example flushes it out to their cache directory under metadata.
JSF Flex Framework
In order to separate the core framework with its implementations, JSF Flex has componentized much of its code into several maven projects that will be linked during build time and its implementations created during runtime. This will allow users to choose their preferred implementation during build time by providing a specific profile id or providing none for the default implementations.
During build time, decision will made of which _RunnerFactory implementation the project should instantiate during runtime [default being DefaultRunnerFactoryImpl] and this implementation will dictate which implementation of _CommonTaskRunner, _FileManipulatorTaskRunner, and _FlexTaskRunner the system should instantiate during runtime. Furthermore, the decision of which implementation of _AnnotationDocletParser to instantiate during run time for specific JRE version will be made during the build time. More details regarding the above process is shown below, which provides a brief overview of each maven project.JSF Flex Maven Projects
- jsf-flex-build-plugIn -- A plug-in project that utilizes qdox open source project to inspect the java file’s documentations in order to generate replaceMapping XML for jsf-flex-framework/component14 project.
- jsf-flex/core -- Contains code pertinent to JSF components. Since the project uses myfaces plug-in, tld, faces_config.xml, tagClass, and etcetera are created during build time.
- jsf-flex/examples -- A WAR project containing sample jsf pages for the project.
- jsf-flex-shared -- A project containing shared resource for jsf-flex and jsf-flex-framework sub-projects. Its main reason of existence is to avoid cyclic dependency between the two projects by providing shared interfaces.
- jsf-flex-framework/core -- Contains the core code that is used by jsf-flex-framework/component14 and jsf-flex-framework/component15 projects.
- jsf-flex-framework/runnerImpl/ commonTaskRunnerImpl -- Contains projects that implement the _CommonTaskRunner interface used by jsf-flex-framework/core [i.e. sdkStandardCommonTaskRunnerImpl project]
- jsf-flex-framework/runnerImpl/ fileManipulatorTaskRunnerImpl -- Contains projects that extends the _FileManipulatorTaskRunner abstract class used by jsf-flex-framework/core [i.e. velocityFileManipulatorTaskRunnerImpl project]
- jsf-flex-framework/runnerImpl/ flexTaskRunnerImpl -- Contains projects that implement the _FlexTaskRunner interface used by jsf-flex-framework/core [i.e. antFlexTaskRunnerImpl project]
- jsf-flex-framework/component14 [JRE < 5] -- For component14, during the build time documentation for java files will be inspected by the JSF Flex plug-in and will generate replaceMapping XML files that will be parsed to check which fields to inspect and how to fetch these fields from the JSF component [by attribute map or by method invocation]. Contains an implementation of _AnnotationDocletParser interface used by jsf-flex-framework/core for fetching the fields from the JSF component [AnnotationDocletParser14Impl].
- jsf-flex-framework/component15 [JRE >= 5] -- Since these components are suppose to be used for JRE >= 5, the attributes will be fetched during runtime through Java annotation and will not require JSF Flex plug-in during build time. Contains an implementation of _AnnotationDocletParser interface used by jsf-flex-framework/core for fetching the fields from the JSF component [AnnotationDocletParser15Impl].
JSF Flex Building SNAPSHOT artifacts
Here I’ll present a brief overview of building snapshot artifacts of JSF Flex.Checking out/Extracting the resources from the repository
Check out/extract the resources from http://jsf-flex.googlecode.com/svn/trunk/ to a folder within the local system [i.e. C:jsfFlexProject] by using the SVN tool.Importing the project into Eclipse IDE
- In the folder where the resources were checked out to, run the following command to enable importing of the projects into an Eclipse IDE [project requires maven for building] :
mvn -D wtpversion=<WTP Version of local Eclipse> eclipse:eclipse
- Then run mvn install within the resource directory [i.e. C:jsfFlexProject]. This should be enough to import the projects into Eclipse IDE.
- Create a new workspace and navigate to File => Import => Existing Projects into Workspace.
- Select the folder where the resources were checked out to [i.e. C:jsfFlexProject].
- Finally add the "M2_REPO" Classpath variable within the workspace:
- Navigate to Window => Preferences => Java => Build Path => Classpath Variables
- M2_REPO as variable and value as the maven2 repository [for me it was "C:/Documents and Settings/Administrator/.m2/repository"]
Projects to import
With the Web 2.0 technology flourishing within the web world, JSF Flex allows bridging of these two technologies which excel in their own area, Flex in creating a Rich Internet Application and Java in maintaining a robust code on the server side.
Specifically the project will provide:
- Easy creation of Flex applications while preserving the ease of databinding to legacy systems through JSF.
- An alternative to purchasing FlexBuilder when creating simple Flex applications.
- Complete abstraction of Flex technology.
Further details and the source code: http://code.google.com/p/jsf-flex/
Project member’s main discussion list: http://groups.google.com/group/jsf-flex/
About the Author
Ji Hoon Kim is a Software Engineer within IBM.