39,59 €
With ADF, Oracle gives you the chance to use the powerful tool used by Oracle's own developers. Modern enterprise applications must be user-friendly, visually attractive, and fast performing. Oracle Fusion Applications are just that; but to get the desired output you need proven methods to use this powerful and flexible tool to achieve success in developing your enterprise applications.
"Developing Web Applications with Oracle ADF Essentials" explains all you need to know in order to build good-looking, user-friendly applications on a completely free technology stack. It explains the highly productive, declarative development approach that will literally have your application running within a few hours, as well as how to use Java to add business logic.
"Developing Web Applications with Oracle ADF Essentials" tells you how to develop and deploy web application applications based on the highly productive and free Oracle ADF Essentials framework. You will first learn how to build business services on top of database tables, and then how to easily build a web application using these services. You will see how to visually design the flow through your application with ADF task flows, and how to use Java programming to implement business logic. Using this book, you can start building and deploying advanced web applications on a robust, free platform quickly.
Towards the end, you will be ready to build real-world ADF Essentials applications and will be able to consider yourself an ADF Essentials journeyman.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 278
Veröffentlichungsjahr: 2013
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2013
Production Reference: 1160813
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78217-068-6
www.packtpub.com
Cover Image by Artie Ng (<[email protected]>)
Author
Sten E. Vesterli
Reviewers
Eugene Fedorenko
Amr Gawish
Dimitrios Stasinopoulos
Acquisition Editors
Erol Staveley
Antony Lowe
Lead Technical Editor
Madhuja Chaudhari
Technical Editors
Anita Nayak
Pragati Singh
Vrinda Nitesh Bhosale
Project Coordinator
Apeksha Chitnis
Proofreader
Paul Hindle
Indexer
Hemangini Bari
Graphics
Ronak Dhruv
Production Coordinator
Aditi Gajjar
Cover Work
Aditi Gajjar
Sten E. Vesterli picked up Oracle development as his first job after graduating from the Technical University of Denmark, and he hasn't looked back since. He has worked with almost every development tool and server Oracle has produced in the last two decades, including Oracle ADF, JDeveloper, WebLogic, SQL Developer, Oracle Portal, BPEL, Collaboration Suite, Designer, Forms, Reports, and even Oracle Power Objects.
He started sharing his knowledge with a conference presentation in 1997, and has since given more than 100 conference presentations at Oracle OpenWorld, ODTUG, IOUG, UKOUG, DOAG, and other user group conferences around the world. His presentations are highly rated by the participants, and in 2010, he received the ODTUG Best Speaker award.
He has also written numerous articles, participated in podcasts, and has written the books Oracle Web Applications 101, The McGraw-Hill Companies and Oracle ADF Enterprise Application Development – Made Simple, Packt Publishing. You can find his blog at www.vesterli.com and follow him on Twitter as @stenvesterli.
Oracle has recognized Sten's skills as an expert communicator on Oracle technology by awarding him the prestigious title of Oracle ACE Director, which is carried by less than 100 people in the world. He is also an Oracle Fusion User Experience Advocate and is a part of the Oracle Usability Advisory Board and participates in the Oracle WebLogic Partner Council.
Based in Denmark, Sten is a partner in the Oracle consulting company Scott/Tiger, where he works as a Senior Principal Consultant. When not writing books or presenting, he is helping customers choose the appropriate technology for their needs, teaching, mentoring, and leading development projects. In his spare time, Sten enjoys triathlons, and he completed his first Ironman in 2012.
As an ADF enthusiast, I'd like to thank Oracle for finally making a free version of Oracle ADF available. With it's high productivity and advanced features, ADF Essentials has the potential to become the standard way of writing data-handling applications. With this book, I hope to help that become a reality.
Others have gone before me in the quest to get the combination of ADF Essentials, MySQL, and GlassFish to work together. I'd especially like to thank Markus Eisele, Duncan Mills, Chris Muir, Jobinesh Purushothaman, Bauke Scholtz, and Shay Shmeltzer, whose work with ADF, Apache Shiro, MySQL, and GlassFish I have benefited from.
I also appreciate the efforts of the people at Packt Publishing who have been supporting this project, as well as my reviewers who have improved the book with their excellent questions and suggestions.
Finally, I'd like to thank my lovely wife for her love, support, and understanding for yet another book project.
Eugene Fedorenko is a senior analyst with extensive experience and management skills. He works for the Ukrainian software company CS Integra. The company focuses on banking software and is a leader in the local market. The company has been an Oracle Platinum partner since 2010 and it was rewarded as the Best Independent Software Vendor in the Eastern Europe region. Eugene graduated from the Kharkiv Aviation Institute in 1999 with an M.Sc. in Computer Science. He began his career in the company in 2000 as a developer. Currently, he is a senior analyst and he is in charge of running projects connected to Oracle Application Development Framework. He is the author of the ADF practice blog http://adfpractice-fedor.blogspot.com and a member of the ADF Enterprise Methodology Group.
Amr Gawish is a Senior Oracle Fusion Middleware Consultant. He is a certified WebCenter Portal and Oracle SOA implementation specialist. He has over five years of experience with the Oracle Middleware stack. He holds a Bachelor's degree in Math and Computer Sciences from Al-Azhar University in Egypt, and he has been involved in many ADF, WebCenter, and SOA projects. He currently works at infoMENTUM, which is an Oracle Gold Partner and a leading company in Oracle Fusion Middleware, and it is the first company to be specialized in WebCenter (both Content and Portal) in the EMEA region. It's what Amr calls "a place where innovation comes true!"
Amr is also currently authoring a book about ADF Faces called Oracle ADF Faces Cookbook, Packt Publishing.
I'd like to thank my wife for helping and encouraging me to complete the review in time, and my daughter for always bringing a smile to my face.
Dimitrios Stasinopoulos is a Certified Application Development Framework Implementation Specialist with more than six years of experience in Oracle Fusion Middleware and, more specifically, in ADF BC 11g. Dimitrios currently works as an Oracle Fusion Middleware Consultant, mainly focusing on Oracle ADF, at e-DBA Ltd., an Oracle Platinum Partner. Dimitrios has worked in several Oracle ADF projects in various positions, from developer to architect, and he also enjoys teaching and talking about Fusion Middleware.
In his spare time, Dimitrios is helping the ADF community by answering technical questions in the Oracle ADF and JDeveloper forum, and he also maintains a blog where he posts his findings and ideas: dstas.blogspot.com.
Dimitrios holds a B.Sc. degree in Computer Science from the Technological Educational Institution of Larissa, Greece.
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.
Oracle ADF is the most productive framework available today for building data-handling web applications. With just a little training (like you can get from this book), you will be able to build fully-functional applications to meet a wide variety of needs.
Until September 2012, this powerful tool was reserved for organizations and projects able to pay for an Oracle WebLogic Server license, which is not quite cheap. But that month, after years of badgering by ADF enthusiasts, Oracle finally decided to make a free, slightly limited version of Oracle ADF available to everyone.
This means the fastest, easiest, and cheapest way of building a data-handling application today is with the technology stack described in this book:
When pharmaceutical companies develop drugs, they are targeting specific ailments or situations. Similarly, IT development platforms and frameworks target specific use cases. And the "sweet spot" for the ADF framework is data-handling applications.
What is a data-handling application? It is an application whose primary function is to gather data, process them, and display them back to the user as tables or graphs. Examples of data-handling applications are membership databases, project and task management, or accounting programs.
With very powerful declarative features, you can build most of your application without having to write any code, and the advanced user interface components make it easy to build an attractive user interface including interactive graphical displays of your data.
After release, some drugs are found to be potentially useful for other conditions than those for which they were developed and tested. This is called "off-label use" — using the drug for something that it was not intended for.
A similar situation occurs in the development of IT systems –– developers choose a tool that is a brilliant choice for one type of applications and try to use it for other types.
The classic case of "off-label use" of ADF is to build an application where you require absolute control over every pixel and every interaction. Such control is often possible to achieve with ADF, but it takes a big effort and requires deep modifications to the core of the framework.
In medicine, some people are allergic to certain medicines and should not be given them.
Similarly, there are some types of highly interactive applications like games or photo editing that are definitely unsuited for ADF.
ADF Essentials contains everything you need to build a data-handling application –– but of course, there has to be some additional features only available to enterprise customers with a full ADF license.
Some of the things not included in ADF Essentials include ADF Mobile, ADF Security (which is based on Oracle Platform Security Services, available only in WebLogic), Web Service Data Controls, ADF Desktop Integration, and so on. Refer to the ADF Essentials "Frequently Asked Questions" document for the full list.
However, it is worth repeating that everything you need in order to build data-handling applications is there. Actually, everything is there –– the restriction is only a legal and licensing issue.
Throughout this book, a sample application for a DVD rental shop is built. You can follow along in JDeveloper as you read, learning ADF hands-on.
The data model is the standard sakila database schema that comes with MySQL. The part we use consists of the customer, film, inventory, and rental tables –– their relationship looks as shown in the following diagram:
We will build three application screens: one simple screen for registering a rental, and two connected screens for searching for a customer and registering a return. These two screens look as shown in the following diagram:
Chapter 1, My First ADF Essentials Application, shows you how to install all the software and build a very simple application to prove that everything works.
Chapter 2, Creating Business Services, describes what Business Components are and how they are used in the example application. No code required!
Chapter 3, Creating Task Flows and Pages, shows you how to build ADF task flows that control the flow of your application and how to build the ADF pages where the user interacts with the data. Still no code required!
Chapter 4, Adding Business Logic, explains how to add business logic to your application –– this is where you'll have to write some actual Java code to implement functionality that ADF does not offer declaratively.
Chapter 5, Building Enterprise Applications,demonstrates how you go about building a larger application, using subsystems and ADF libraries to divide a big application into more manageable parts. We'll quickly build the whole DVD rental application again in this chapter using proper enterprise methodology.
Chapter 6, Debugging ADF Applications, shows you how to use ADF logging and debugging features to troubleshoot any problems you might experience during your ADF development.
Chapter 7, Securing an ADF Essentials Application,implements Apache Shiro to secure your application. Remember that there were some ADF-specific security features not part of ADF Essentials? This chapter shows you a fully-functional alternative.
Chapter 8, Build and Deploy,demonstrates how to use Apache Ant to create build scripts that compile, build, and deploy an entire enterprise application, including subsystems and ADF libraries.
This book uses the following software:
Chapter 1, My First ADF Essentials Application, explains where to get the software, how to install it, and how to configure all the parts to work together.
This book is for every web developer who wants to build data-handling applications quickly and efficiently. The book does not require any preconditions –– even beginners can use the powerful declarative features of ADF to build basic applications completely without programming.
Most real-life applications will of course require some programming to implement the business logic that is specific to your application. ADF uses Java to implement business logic, so a basic understanding of Java programming is required for most applications. A bit of knowledge about web applications in general will also be beneficial.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the erratasubmissionform link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.
In this chapter, we will install all the necessary (free!) software that we will be using throughout the book to build applications using Oracle Application Development Framework (ADF). We'll need:
For the purposes of this book, we will be using the popular and free MySQL database. However, you can run Oracle ADF Essentials applications on any other SQL database—so if you're a PostgreSQL fan, you don't have to change. You can also use commercial databases—Oracle is offering Oracle Database Express Edition if you are looking for a free version of an enterprise product.
Don't plan on running Oracle Database Express Edition directly on your development machine if it is 64-bit Windows—this is not supported and won't work. To run Oracle XE, you'll either need Linux, an old 32-bit Windows install, or run your database inside a 32-bit Windows virtual machine.
Similarly, you can run your ADF Essentials application on any JEE application server. This book will describe how to use GlassFish, but you could also use other open source JEE servers like JBoss or commercial offerings like Oracle WebLogic.
As our development tool, we will be using Oracle's preferred development tool, Oracle JDeveloper. This free tool is currently the only supported way of building Oracle ADF Essentials applications, but Oracle is working on supporting ADF Essentials as part of their Oracle Enterprise Pack for Eclipse (OEPE) product.
With Eclipse and Oracle Enterprise Pack for Eclipse, you can already build ADF applications for WebLogic. However, the tool does not yet support building applications for ADF Essentials.
To simplify the instructions in this book, you should create a directory called adfessentials and install everything there.
On Windows, place this directory in the root of your C: drive as C:\adfessentials.
On Mac/Linux, place this directory in the root of your filesystem as /adfessentials. You will typically be prompted for a system administrator or root password when creating the directory.
The MySQL server exists in both a Community Server edition and an Enterprise Edition. The Enterprise Edition is the commercial version that has additional features and a price tag—in this book, we will use the free Community Server edition Version 5.6.12. This can be downloaded from http://dev.mysql.com/downloads/mysql.
Would you like support with that?
Now is a good time to think about whether you want your installation to be commercially supported. If you are setting up a development environment or just want to run a membership application for your local little league baseball team, you probably don't need commercial support and can go with the open source/community options.
On the other hand, if you are setting up a production environment, think about whether you or someone else in your organization feels confident that they can handle any issues that might occur. If you would like to be able to call on the friendly people from Oracle Support to help you, you need to set up the commercial version and purchase a support contract from Oracle.
If you choose the Windows platform, you will be given the option to download the MySQL Installer MSI package as shown in the following screenshot:
When you click on the Download link, you will be taken to a page where you can select from two MSI Installer packages as shown in the following screenshot:
Choose the larger one to get everything in one download. The smaller option means that you download only the installer program first, and this program will then download the rest of the software.
If you are running Mac OS X, you have an option to select either a compressed TAR file or a DMG installer as shown in the following screenshot:
For the easiest installation, choose the DMG installer file that matches your OS X version and architecture. If you have a fairly recent Mac, you should choose OS X 10.7, 64-bit.
If you are running Linux, choose your distribution from the Platform options (or Linux – Generic if your distribution is not listed), and then choose the download that matches your Linux version and architecture (32- or 64-bit).
Once you have chosen your download, you will be prompted to sign up for a free Oracle Web account (or log in with an existing account) when you click on the Download link. You will need this account in order to download the ADF Essentials software and JDeveloper, and probably later for other downloads as well.
This section will walk you through the installation of the MySQL database on Windows – if you are running another operating system, the process is similar.
Some installation options of some Linux distributions install MySQL by default. If you are running Linux, you might want to check if you already have MySQL.
Start the installer, click on OK to any warnings about installing software and changing your machine, and choose Install MySQL Products. Read and accept the license agreement and allow it to check for later versions of the software.
For the purposes of this book, you can simply choose a Developer Default setup type when prompted. If you already know MySQL and have specific ideas about your installation, feel free to change the options.
Change the installation path to C:\adfessentials\MySQL\product and the data path to C:\adfessentials\MySQL\data.
On Mac and Linux, the installer might simply decide to place the software and data in /usr/local. That's fine, too.
In the Check Requirements step, you may be prompted to install various additional packages—simply accept this. If you are told that you are missing various versions of the Python programming language, you can just click on Execute a few times to acknowledge the warnings.
The Developer Default installation includes database connectors for Python, but if you are not using Python, they can't be installed. That's OK.
Once you are done with this step, the installer starts installing the actual MySQL software as shown as follows:
When the software is installed, you can click on Next a few times to start the configuration. The first screen looks like this:
On this screen, you can leave the defaults:
In step 2 shown in the following screenshot, you are asked to provide a root password for the database. You can always create separate users later.
If this is a non-critical development workstation, and you want to be sure that you have the password written down, feel free to use this example password: ADFsecret/13.
The default installation on Mac and Linux sets a blank root password, which is probably a bit too relaxed. To set the password on Mac/Linux, execute the following command:
Press return when prompted for a password (the prompt is for the old, empty password) and then provide a new password twice.
In step 3, you are prompted for a Windows service name as shown in the following screenshot:
You can leave the defaults on this screen.
When you click on Next, the configuration of MySQL runs. When this is complete, click on Next to install the samples and examples and then finish the installation.
JDeveloper generates code with two vertical bars (|| or pipes) for string concatenation, and while this is valid SQL92, it is not supported in a default MySQL configuration. To enable this in MySQL, find the MySQL configuration file my.ini in the database directory (for example, C:\adfessentials\MySQL\data).
Search for a line starting with sql_mode=. If such a line exists, add a comma after the existing value and then the keyword PIPES_AS_CONCAT. If there is no sql_mode line, add the following:
If you come from an Oracle background, you might want to set sql_mode=ORACLE instead—this sets PIPES_AS_CONCAT and a couple of other settings to make MySQL behave more Oracle-like.
You will need to restart the MySQL database in order for this change to take effect. On Windows, you can open the Control Panel, choose Administrative Tools, and then Services. Find the MySQL56 service and choose Action | Restart. You can also restart the database from the MySQL Workbench by double-clicking on your database in the Server Administration column to the right.
Once you have your Sakila database installed, you can start the MySQL Workbench from the Start menu. You should see Local instance MySQL56 or similar to the left under the SQL Development heading, as shown in the following screenshot:
You can double-click on this and provide your root password to connect to the database. If an SQL Editor window opens with various schemas to the left (including your Sakila database) as shown in the following screenshot, your installation was successful:
If you prefer to use a command line, you can start the MySQL 5.6 Command Line Client from the Start menu, provide your root password, and type the following command:
If you see a couple of databases as in the following screenshot, your MySQL server is running correctly:
The MySQL command line can also be started from a command prompt by running the following command:
This attempts to log in as user root and prompts you for the password.
