With the release of JSF 2.0 and ICEfaces 2.0.x, a common situation arises of porting and converting existing ICEfaces 1.8.x. This tutorial will demonstrate the required steps to convert a legacy application to "compat mode" in ICEfaces 2.0. This means you can still use your existing ice: components and backing beans, but aren't yet taking advantage of 2.0 specific features and benefits. The majority of the converting effort involves configuration files and libraries, so most of your page markup won't need to be significantly changed.
This tutorial assumes the reader has a basic understanding of JSF and ICEfaces, especially creating and working with projects related to those technologies. The focus is not to teach the foundations, but instead to learn about porting applications.
The goal of this tutorial is to examine a real world ICEfaces 1.8.x application. Once we have an understanding of the project we will begin the steps to port the application to ICEfaces 2.0. The application is a slightly modified version of the "jobApplication" used in the ICEfaces Online Training. There is a central form based page that can redirect to two pages based on different outcomes.
The following tools were used to create the project.
- Eclipse IDE for Java EE Developers - Version Galileo
- Tomcat 6.x Web Server
- Java 6.x
- ICEfaces 1.8.2 and ICEfaces 2.0 Beta 2
|1.8 jobApplication project||[jobApplication source code |^jobApplication-1.8.zip|Download Source Code]||The Eclipse workspace of the jobApplication project written in ICEfaces 1.8.|
Download and extract the above source code bundle, and Import -> Existing Project into Workspace the folder into your Eclipse instance. Build and deploy the application to your Tomcat instance, and navigate to the deployed jobApplication. You will see a page similar to the following:
Now let's examine the page code, to get a better idea of what the application is doing. There are three main pages:
- Main page that has a series of internationalized form fields with validation, partialSubmit, a ice:selectInputDate component, etc.
- Basic page redirected to when the first name equals "John".
- Similar page redirected to when the first name is anything else.
The Java code is fairly standard for 1.8, focusing on two beans:
- Controller/backing bean for the applicantForm.xhtml page. This controls the submission and some of the rendering toggles on that page.
- Model object containing variables for the different Applicant fields, like First Name and Travel Percentage. No UI specific functionality.
- Supporting Beans
- The ProvinceSupport.java and Province.java classes are used to back the available items in the ice:selectOneMenu found on the main page.
- The messages_en.properties and JSF-override_en.properties are used to internationalize the various form labels.
Now that we understand the project a bit better, we'll start the 1.8 to 2.0 conversion process.