Learn Oracle ADF with Examples: How to Build Modern and User-Friendly Applications
Oracle ADF Survival Guide: Mastering the Application Development Framework
If you are an experienced developer who wants to rapidly become productive with Oracle's Application Development Framework (ADF) 12c, this article is for you. In this article, you will learn what Oracle ADF is, why you should use it, how to get started with it, how to build modern, user-friendly applications with it, and how to master the application development framework with it.
Oracle ADF Survival Guide: Mastering the Application Development Framework mobi download book
What is Oracle ADF?
Oracle ADF is a Java EE framework for building enterprise applications that run on any platform. It provides a complete solution for developing rich web interfaces, business logic, data access, security, testing, deployment, and maintenance.
Oracle ADF consists of four main layers:
ADF Faces: This layer provides a set of over 150 web components that you can use to create user interfaces with Ajax functionality, data visualization, accessibility, internationalization, and mobile support.
ADF Task Flows: This layer provides a way to define the navigation logic of your web pages using graphical diagrams that show the possible outcomes of user actions.
ADF Business Components: This layer provides a way to create data models based on existing database tables, views, stored procedures, or web services. You can also define business rules, validations, calculations, and transactions using declarative tools.
ADF Model: This layer provides a way to bind your user interface components to your data model using expressions and iterators. It also handles data caching, synchronization, and events.
Why use Oracle ADF?
Oracle ADF offers many advantages for developing enterprise applications, such as:
Productivity: You can use the drag-and-drop features of JDeveloper, the integrated development environment (IDE) for Oracle ADF, to create your application components without writing much code. You can also use wizards, templates, and code generators to speed up your development process.
Reusability: You can create reusable components that can be shared across multiple applications or modules. You can also use existing Java libraries, web services, or Oracle Forms applications as part of your ADF application.
Maintainability: You can use the declarative tools of Oracle ADF to define your application behavior without hard-coding it. This makes it easier to modify or extend your application functionality without affecting other parts of the application.
Integration: You can use Oracle ADF to integrate with various technologies and platforms, such as Oracle Database, Oracle Fusion Middleware, Oracle Cloud, Java EE, RESTful web services, SOAP web services, XML, JSON, and more.
How to get started with Oracle ADF
To start developing applications with Oracle ADF, you need to install and configure Oracle ADF and JDeveloper on your system. Here are the steps to do that:
Installing Oracle ADF
Download the latest version of Oracle ADF 12c from https://www.oracle.com/middleware/technologies/adf-downloads.html.
Extract the downloaded zip file to a folder of your choice.
Run the installer file (setup.exe on Windows or runInstaller on Linux) and follow the instructions on the screen.
Select the option to install Oracle ADF Runtime and Oracle JDeveloper Studio.
Specify the installation directory and the JDK location.
Review the installation summary and click Install.
Wait for the installation to complete and click Finish.
Configuring JDeveloper
Launch JDeveloper from the Start menu (on Windows) or from the bin folder (on Linux).
Select the default role as Studio Developer and click OK.
Select a user home directory and click OK.
Select a migration directory and click OK.
Select a tip level and click OK.
Select a look and feel and click OK.
Select an update center and click OK.
JDeveloper will open with a welcome page. You can close it or explore it as you wish.
How to build modern, user-friendly applications with Oracle ADF
To demonstrate how to use Oracle ADF to create a simple web application with a database connection, we will follow these steps:
Create an ADF application project in JDeveloper.
Create an ADF business component based on an existing database table.
Create an ADF task flow to define the page flow logic.
Create an ADF facelet page to display the data from the database table.
Run and test the application on an integrated web server.
Creating an ADF application project
In JDeveloper, select File > New > Application from the main menu.
In the New Gallery dialog box, select Applications > Fusion Web Application (ADF) and click OK.
In the Create Fusion Web Application (ADF) dialog box, enter a name for your application (for example, MyADFApp) and a directory to store it. Click Next.
In the Application Package Prefix dialog box, enter a package prefix for your application (for example, com.mycompany). Click Next.
Creating an ADF business component
In JDeveloper, right-click on the MyADFAppModel project and select New > Business Components > Business Components from Tables from the context menu.
In the Create Business Components from Tables wizard, select a database connection or create a new one. Click Next.
In the Entity Objects step, select a table from the available tables list (for example, EMPLOYEES) and click the right arrow button to move it to the selected tables list. Click Next.
In the View Objects step, select a view object from the available view objects list (for example, EmployeesView) and click the right arrow button to move it to the selected view objects list. Click Next.
In the Application Module step, enter a name for your application module (for example, MyADFAppModule) and click the right arrow button to move it to the selected application modules list. Click Next.
In the Package step, enter a package name for your business components (for example, com.mycompany.model). Click Finish.
JDeveloper will create an entity object, a view object, and an application module for your ADF business component. You can see them in the Application Navigator under the MyADFAppModel project.
Creating an ADF task flow
In JDeveloper, right-click on the MyADFAppViewController project and select New > Web Tier > JSF/Facelets > ADF Task Flow from the context menu.
In the Create ADF Task Flow dialog box, enter a name for your task flow (for example, MyADFAppTaskFlow) and a directory to store it. Click OK.
JDeveloper will open the task flow diagram editor. You can see a default task flow with two activities: methodCall1 and return1.
Drag and drop a View activity from the Component Palette to the task flow diagram. Double-click on it and enter a name for your view (for example, MyADFAppPage).
Drag and drop a Control Flow Case from the Component Palette to connect methodCall1 to MyADFAppPage. Double-click on it and enter an outcome value (for example, showPage).
Drag and drop another Control Flow Case from the Component Palette to connect MyADFAppPage to return1. Double-click on it and enter an outcome value (for example, goBack).
You have created a simple task flow that shows a web page when methodCall1 returns showPage and returns to the caller when MyADFAppPage returns goBack.
Creating an ADF facelet page
In JDeveloper, right-click on the MyADFAppViewController project and select New > Web Tier > JSF/Facelets > JSF Page from the context menu.
In the Create JSF Page dialog box, enter a name for your page (for example, MyADFAppPage) and a directory to store it. Select Facelets as the document type and click OK.
JDeveloper will open the visual editor for your page. You can see a default page with a panelGroupLayout component.
Drag and drop an ADF Data Control from the Data Controls panel to your page. Select MyADFAppModuleDataControl > EmployeesView1 > Attributes[EmployeesView] > All Attributes[EmployeesView] and drop it as an ADF Read-only Form.
JDeveloper will create an ADF read-only form with all the attributes of EmployeesView1 on your page. You can see them in the Structure window under af:form > af:panelGroupLayout > af:panelFormLayout.
Drag and drop another ADF Data Control from the Data Controls panel to your page. Select MyADFAppModuleDataControl > EmployeesView1 > Operations and drop it as an ADF Button Group.
JDeveloper will create an ADF button group with four buttons: First, Previous, Next, and Last on your page. You can see them in the Structure window under af:form > af:panelGroupLayout > af:buttonBar.
You have created a simple web page that displays data from EmployeesView1 and allows navigation through records using buttons.
Running and testing the application
In JDeveloper, right-click on the MyADFAppViewController project and select Run from the context menu.
JDeveloper will deploy and run your application on an integrated web server. It will open a browser window with your web page.
You can see the data from EmployeesView1 in the read-only form. You can use the buttons to navigate through different records.
You can also see the URL of your web page in the browser address bar. It should look something like this: http://localhost:7101/MyADFAppViewController-ViewController-context-root/faces/MyADFAppTaskFlow.jsf
You have successfully created, deployed, and tested a simple web application with Oracle ADF.
How to master the application development framework with Oracle ADF
To become an expert in developing enterprise applications with Oracle ADF, you need to learn more about the advanced topics and best practices for using Oracle ADF. Here are some of the topics that you should explore:
Layout and skins
Layout and skins are two aspects of Oracle ADF that help you customize the appearance and behavior of your web pages. Layout components allow you to arrange your user interface components in a structured and responsive way. Skins allow you to change the look and feel of your user interface components by applying stylesheets and images.
Some of the layout components that you can use in Oracle ADF are:
af:panelGridLayout: This component allows you to create a grid layout with rows and columns that can span multiple cells and adjust to different screen sizes.
af:panelSplitter: This component allows you to create a splitter layout with two or more panels that can be resized by dragging a splitter bar.
af:panelTabbed: This component allows you to create a tabbed layout with multiple tabs that can contain different content.
af:panelAccordion: This component allows you to create an accordion layout with multiple panels that can be expanded or collapsed by clicking on a header.
af:panelDashboard: This component allows you to create a dashboard layout with multiple tiles that can contain different content and be rearranged by dragging and dropping.
Some of the skin features that you can use in Oracle ADF are:
Alta UI: This is the default skin for Oracle ADF 12c applications. It provides a modern, flat, and responsive design that adapts to different devices and screen sizes.
Skin Editor: This is a tool that allows you to create and edit skins for your Oracle ADF applications. You can use it to change colors, fonts, images, borders, margins, paddings, and more.
Skin Selectors: These are CSS selectors that allow you to target specific user interface components or states for styling. You can use them to apply different styles for different components, facets, variants, types, modes, or states.
Skin Properties: These are CSS properties that allow you to define values for styling attributes. You can use them to set values for colors, fonts, images, borders, margins, paddings, and more.
Skin Functions: These are CSS functions that allow you to perform calculations or transformations on values for styling attributes. You can use them to adjust values for colors, fonts, images, borders, margins, paddings, and more.
Business logic
Business logic is the part of Oracle ADF that implements the rules and calculations that govern your application data and behavior. You can define business logic using ADF business components in a declarative or programmatic way.
Some of the business logic features that you can use in Oracle ADF are:
Entity Object Attributes: These are properties that represent the columns of a database table or view in your entity object. You can use them to define data types, default values, primary keys, foreign keys, sequences, validations, calculations, and more.
Entity Object Associations: These are relationships that link two entity objects based on common attributes. You can use them to define referential integrity constraints, cascading operations, composition associations, and more.
Presentation logic
Presentation logic is the part of Oracle ADF that adds interactivity, navigation, validation, and security features to your web pages. You can define presentation logic using ADF faces components in a declarative or programmatic way.
Some of the presentation logic features that you can use in Oracle ADF are:
ADF Faces Components: These are over 150 web components that you can use to create user interfaces with Ajax functionality, data visualization, accessibility, internationalization, and mobile support. Some examples of ADF faces components are: buttons, links, menus, dialogs, tables, trees, charts, gauges, maps, calendars, and more.
ADF Faces Converters: These are components that convert data values between different types or formats. You can use them to convert data values between Java types and display formats, such as numbers, dates, currencies, and more.
ADF Faces Validators: These are components that validate data values against certain rules or constraints. You can use them to validate data values for required fields, length limits, range limits, regular expressions, and more.
ADF Faces Event Listeners: These are components that listen for user actions or component events and execute some logic or navigation. You can use them to handle actions such as clicks, selections, changes, validations, phases, and more.
ADF Faces Partial Page Rendering: This is a feature that allows you to update only a part of your web page without refreshing the whole page. You can use it to improve the performance and responsiveness of your web pages.
ADF Faces Data Binding: This is a feature that allows you to bind your user interface components to your data model using expressions and iterators. It also handles data caching, synchronization, and events.
ADF Faces Security: This is a feature that allows you to secure your web pages and components based on user roles and permissions. You can use it to restrict access to certain pages or components based on user authentication and authorization.
Logging and debugging
Logging and debugging are two aspects of Oracle ADF that help you monitor and troubleshoot your application performance and errors. Logging allows you to record messages or events in your application for later analysis. Debugging allows you to examine and modify the state of your application at runtime.
Some of the logging and debugging tools that you can use in Oracle ADF are:
JDeveloper Log Window: This is a window in JDeveloper that displays messages or events from various sources in your application. You can use it to view messages from the integrated web server, the ADF Model layer, the ADF Business Components layer, the JSF lifecycle phases, and more.
JDeveloper Debugger: This is a tool in JDeveloper that allows you to debug your application code at runtime. You can use it to set breakpoints, watch variables, evaluate expressions, modify values, step through code, and more.
JDeveloper Profiler: This is a tool in JDeveloper that allows you to profile your application performance at runtime. You can use it to measure the execution time and memory usage of your application code and identify performance bottlenecks.
ADF Model Tester: This is a tool in JDeveloper that allows you to test your data model at design time. You can use it to execute queries, view data values, update data values, invoke methods, and more.
ADF Declarative Debugger: This is a tool in JDeveloper that allows you to debug your declarative settings at runtime. You can use it to inspect and modify the values of your bindings and properties.
ADF Logger: This is a class in Oracle ADF that allows you to log messages or events in your application code. You can use it to log messages with different levels of severity and categories.
ADF Diagnostics Framework: This is a framework in Oracle ADF that allows you to collect diagnostic information from various sources in your application. You can use it to collect information from the ADF Model layer, the ADF Business Components layer, the ADF Faces layer, and more.
Your ADF workflow
Your ADF workflow is the process that you follow to manage your application lifecycle. It involves using various tools and techniques to perform tasks such as version control, testing, deployment, and maintenance.
Some of the tools and techniques that you can use in your ADF workflow are:
Version Control: This is a technique that allows you to track and manage changes to your application code and resources. You can use it to store your application files in a repository, compare different versions of files, merge changes from different sources, and more.
Testing: This is a technique that allows you to verify the functionality and quality of your application. You can use it to perform unit testing, integration testing, functional testing, load testing, and more.
Deployment: This is a technique that allows you to package and distribute your application to different environments. You can use it to create deployment profiles, deployment archives, deployment plans, and more.
Maintenance: This is a technique that allows you to update and improve your application over time. You can use it to fix bugs, add features, optimize performance, and more.
Conclusion
In this article, you have learned how to use Oracle ADF to develop enterprise applications with a minimum of coding. You have learned what Oracle ADF is, why you should use it, how to get started with it, how to build modern, user-friendly applications with it, and how to master the application development framework with it.
Oracle ADF is a powerful and productive framework that provides a complete solution for developing rich web interfaces, business logic, data access, security, te