As you've seen in previous columns, Oracle JDeveloper 10g and Oracle Application Development Framework (ADF) provide a complete development environment with a host of declarative features similar to 4GL tools you may have used in the past. To help you make the most of the powerful Oracle JDeveloper/ADF combination, the Oracle ADF Learning Center provides numerous helpful resources, such as ADF Developer's Guide for Forms/4GL Developers , a companion sample application, and an end-to-end tutorial.
This column shows you another powerful tool to help you harness the potential of Oracle JDeveloper: the Oracle JHeadstart application generator. It demonstrates the new Oracle JHeadstart 10.1.3 version to show you how quickly you can create real-world applications in Oracle JDeveloper.What Is Oracle JHeadstart?
Oracle JHeadstart is an Oracle JDeveloper extension, developed by Oracle Consulting, that generates Web-tier code for application modules. It was developed as a result of years of real-world experience by Oracle consultants who have built many hundreds of applications for their customers. It was designed to make the advanced features of both Oracle ADF and JavaServer Faces (JSF) easier to use in your own Web applications.
Oracle JHeadstart works by adding a set of integrated editors to the Oracle JDeveloper environment. By using these editors, along with the data model you've designed for your Oracle ADF business service, you create and iteratively refine a high-level application definition for your project. This application definition lets you control the functionality and organization of information in your Web user interface, based on the view objects in your application module's data model.
The application definition editor in Oracle JHeadstart lets you describe a logical hierarchy of pages that can include forms, tables, wizards, search regions, lists of values (LOVs), shuttle pickers, and other features standard in modern Web user interfaces (UIs). Furthermore, Oracle JHeadstart uses terminology familiar to Oracle Forms and Oracle Designer users, to make it easier for you to make declarative choices for your application definition.
The Oracle JHeadstart application generator doesn't actually generate Java code. Instead, it creates (or regenerates) all of the declarative artifacts for the view and controller layers within your Oracle ADF-based Web application. These artifacts use your Oracle ADF application module as their business service and your Oracle ADF Model layer for declarative data binding. The generated files Oracle JHeadstart creates are the same ones you would produce on your own when using Oracle JDeveloper's built-in visual editors. The key difference is that Oracle JHeadstart creates them en masse, based on a higher-level application definition you can iteratively refine until the generated pages match your end users' requirements.
The generated files include
JSF application pages with data-bound ADF Faces UI components
Oracle ADF Model page definition XML files describing each page's data bindings
JSF managed bean settings and navigation rules to handle application page flow
Generating Your First Web Application
Once you're satisfied with your Oracle JHeadstart-generated pages, you can use the Oracle JDeveloper development environment to fine-tune your UI or develop additional pages. If you modify an Oracle JHeadstart-generated page, you can adjust the generator templates so the page adheres to your specifications on subsequent runs of the application generator, or you can set a flag to prevent the customized page from being regenerated at all. Because the Oracle JHeadstart-generated pages and your custom-designed pages both leverage the same Oracle ADF Faces UI components, your pages will all automatically inherit a consistent look and feel.
The best way to appreciate what Oracle JHeadstart can do is to take the fully functional trial edition for a spin. In this section, I'll experiment with just a few of Oracle JHeadstart's many application generation preferences, using the familiar EMP and DEPT tables in the SCOTT schema. You can find installation instructions for the Oracle JHeadstart 10.1.3 trial edition at the Oracle JHeadstart Product Center on OTN (oracle.com/technology/consulting/9iServices/JHeadstart.html). After installing it, check the Extensions tab of the Oracle JDeveloper Help-> About dialog box to ensure that you see the Oracle JHeadstart extension.
In Oracle JDeveloper, start by creating a new application, using the Web Application [JSF, ADF BC] template. Right-click the Model project, select New , and start the Business Components from Tables wizard from the New Gallery dialog box. (Because I've performed these tasks in previous columns, I'll go through the steps quickly, but if you need a more basic walk-through of Oracle JDeveloper, check out any of the past Frameworks articles.) In the wizard, specify oramag.model as the package name and create default entity objects and updatable view objects based on the EMP and DEPT tables. Name your application module HRModule , and do not create any read-only view objects.
Next, edit the HRModule component to provide more-meaningful names for your default view object instances. To do so, right-click HRModule from the Applications Navigator and open the Application Module Editor. Select the Data Model panel, and rename the DeptView1 , EmpView2 , and EmpView1 view instances to Departments , DepartmentStaff , and Employees , respectively.
Now that you have a simple application module in place, you can use Oracle JHeadstart to generate a Web application for it. Start by right-clicking the ViewController project from the Application Navigator and selecting Enable JHeadstart on this Project . On the title page of the JHeadstart Enable Project wizard, click Next , and then click Finish . After the wizard performs the required configuration steps, click Finish again to exit the wizard. Click the Save All toolbar button to save all the changes.
Now you can add a new Oracle JHeadstart application definition. Right-click the ViewController project again, and select New JHeadstart Application Definition . On the first page of the New JHeadstart Application Definition wizard, choose HRModuleDataControl as the data control to use for your Web application. It should actually be selected by default, because it's the only one in your workspace. Leave the Create default Groups for all Data Collections check box checked. This setting creates a default application definition, based on the view objects in your application module's data model, which you then can modify to fit your needs. Click Next , and keep the defaults for the service name and application definition XML filename on the next page that appears. Click Next again, and check the Generate LOV's instead of dropdown lists? check box. Leave the default layout styles for parent and child groups, and click Next . Click Finish on the next screen, and the wizard will create a new Oracle JHeadstart application definition. Finally, click Finish again to close the dialog box and click Save All to save all the changes.
After you've saved all your project files, right-click the ViewController project again and select Edit JHeadstart Application Definition , which launches the JHeadstart Application Definition Editor. You will use this editor later to fine-tune your application generation options. For now, simply note that this editor is a modeless window that you can keep open at the same time as your main Oracle JDeveloper IDE window. The editor displays the hierarchical structure of the groups of information that constitute the pages of your Web application. Note that the structure initially mimics the hierarchical structure of the view objects in the data model of your HRModule.
Now run the Oracle JHeadstart application generator. By running it now, you can see the kind of Web application you get when using the default application definition settings. To run the application generator, click the Run the JHeadstart Generator toolbar button in the Application Definition Editor or right-click the ViewController project from the Application Navigator and select Run JHeadstart Application Generator . When the Generation Finished alert appears, click OK .Running the Default Application
To run the application, right-click the ViewController project from the Application Navigator and select Run . Oracle JDeveloper launches the embedded Oracle Containers for J2EE (OC4J) server and opens the generated application in your Web browser, using a tabbed display. If you toggle between your browser window and the JHeadstart Application Definition Editor, you'll see that each top-level group in the application definition is rendered as a separate top-level tab in your UI. On the Departments page, click the DepartmentStaff button to drill down to the related staff members in that department. As you do so, note that a navigation guide known as breadcrumbs appears above the page title to show you where in the Web site hierarchy you are. Now click the Employees tab, and note that the page defaults to a table display style, featuring page-by-page scrolling and the ability to easily perform multirow inserts, updates, and deletes. If you click the Save button, all your changes will be saved.
Note that the Deptno field includes a list-of-values lookup function you can invoke from either the search region or the data entry area by clicking the flashlight icon. Also, note that if you make changes to data on the Employees page and then try to click the Departments page, you'll receive a warning saying you'll lose your edits if you continue.
All of this functionality is built in to your Oracle JHeadstart-generated pages with the default settings. What's even better is that virtually every aspect of both the layout and features of your pages can be controlled by an appropriate application definition setting. The next section looks at a few of them. If you're curious, try double-clicking one of the generated *.jspx pages in your project to open it in the Oracle JDeveloper visual editor. By default, Oracle JHeadstart generates them in the WEB-INF/page subdirectory of the Web Content folder in the Application Navigator. All the features that Oracle JHeadstart generates correspond to capabilities you could implement, one page at a time, with the Oracle JDeveloper 10g integrated development environment—but doing so would require a strong knowledge of JSF, the Oracle ADF Faces component library, Oracle ADF's declarative features, the framework best practices, and custom coding for more-advanced behaviors. Using Oracle JHeadstart, you can get a really professional result with a lot less work, even before you become an Oracle ADF and JSF expert.Customizing Preferences and Regenerating
As the first simple customization, let's change the way items in the Employees group are laid out on the page. Currently the items are all displayed as columns in a table, but you'll move some of them to appear in the table's "overflow area" instead. You'll also change the number of rows per page to five.
In the JHeadstart Application Definition Editor, expand the top-level Employees group and select that Employees node. Set its Table Overflow Style property to right and the Table Range Size property to 5 . Click the Job attribute and then shift-click the Deptno attribute to select all of the attributes from Job to Deptno . Set the Display in Table Layout? property for these attributes to false and the Display in Table Overflow Area? property to true . Finally, to indicate that you want to allow the user to enter a value for the employee ID only when creating a new employee, select the Empno attribute and set its Update Allowed? property to while_new .
When you generate the application, the items in the table overflow area appear to the right of the table. You can organize these items into logical groups by creating two new constructs called item regions. Do so by right-clicking the Regions folder under the Employees group and selecting Add Child->Item Region . Set the Name and Title properties of the new item region both to Functional . Repeat the above step to define a second item region named and titled Financial . Drag and drop the Job , Mgr , and Hiredate attributes into the Functional item region folder, and drag and drop the Sal and Comm attributes into the Financial region folder. Finally, select the Regions folder itself and set its Layout Style property to stacked . This setting will cause the two named item groups to be laid out as separate tabs within the page.
When you have parent and detail groups, such as Departments and DepartmentStaff in this example, you can easily control where the detail group is shown relative to the parent. As you saw above, the detail group is shown by default on a separate drill-down page. To make department staff data appear on the same page as the parent, select the DepartmentStaff detail group (which is nested below the Departments group) and set its Same Page property to true by checking the check box. Then select the Departments group and set its Layout Style property to table .
Now rerun the Oracle JHeadstart application generator and run the application. You should now see departments and department staff on the same page, as well as a hybrid table/tab display on the Employees page, as shown in Figure 1. If you check the source directory of your ViewController project, you'll be pleased to find that Oracle JHeadstart fully embraces the declarative spirit of Oracle ADF development. In fact, none of its sophisticated user interface features require any generated Java code whatsoever!
|Figure 1: Employees group with table layout and overflow area with stacked regions|
Hopefully these examples will whet your appetite to try the free trial edition of Oracle JHeadstart with your own application tables. The simple examples shown here only scratch the surface of Oracle JHeadstart's application generation flexibility. In addition to an impressive set of built-in capabilities, Oracle JHeadstart also provides a powerful templating mechanism that can tailor the application generator to meet virtually any business requirement you might have.
Like Oracle ADF itself, Oracle JHeadstart comes with an excellent, detailed developer's guide that walks you through every generation option and advanced feature. You can visit the Oracle JHeadstart product center on OTN for additional online product demos, tutorials, and white papers, as well as details on pricing, support, and related consulting services.
READ more about Oracle JDeveloper 10g and Oracle ADF
Photography by Syda Productions, Shutterstock