Thursday, September 9, 2010

ADF Model: Creating View Object (VO)

View Object (VO) is build on one or more entity objects. Please follow the below steps to create VO.


1. In Model project, right click on any package, select 'New View Object..'

2. Now, 'Create View Object' wizard appears -> In the 'Name' stop, Give Name for the VO, select/give correct package for the VO. The VO Name is generally follows the convention <objectname>VO. For e.g., EmpVO

3. Click 'Next' -> In the 'Entity Objects' section, select the EOs on which you want create the VO and shuffle to the right side.

4. Click 'Next' -> In the 'Attributes' section, select the EO attributes you want to include in the VO and shuffle them to the right side.

5. Click 'Next' -> In the 'Attribute Settings' section, you can give settings for each of the VO attributes.

6. Click 'Next' -> The 'Query' section displays the VO query along with the generated Where clause.

7. You can add 'Order By' clause to the query in 'Order By' filed. You can 'Edit..' and select the 'Order By' attribute'

8. Click 'Next' -> In the 'Bind Variables' section, you can add one or more bind variables. Bind variables are used to form parameterized queries.

9. Click 'Next' -> In 'Java' section, you can opt to select ViewObject class and VO row class etc.

10. Click 'Next' -> In the 'Application Module' section, you can check 'Application Module' check box and create application module to add this VO.

11. Click 'Next' to see the summary of the VO and then click 'Finish'.

12. Now, you'll find the newly created Association in model project under the specified package.

Creating DB Connection in Jdeveloper

The basic requirement in Jdeveloper is to connect to database and execute queries in Jdeveloper. We'll see how to do it in below steps.

1. Check if 'Database Navigator' palette is open in Jdeveloper. If now, cick on 'View' and select 'Database Navigator'.

2. In the 'Database Navigator', Right click 'IDE Connections' and select 'New Connection'.

3. In the 'Create Database Connection' window, give Name for the connection, select the type of DB you want to connect.

4. Give the connection details for the DB. You can give database connection URL by checking 'Enter Custom JDBC URL'. Test your connection and click 'OK'.

5. Now, you can see the newly created DB under 'IDE Connections'. Select it and Right Click and select 'Connect'.

6. It'll open SQL editor window where you can type and execute your queries (It is same as Oracle SQL Developer).

7. Alternatively, you can also connect to DB by clicking on the 'SQL' icon and selecting the appropriate DB connection.

ADF Model: Creating Entity Association

An Entity Association defines the relationship between two entities or EOs. Follow the below steps to create an entity association.

1. In Model project, right click on any package, select 'New Association'.

2. Now, 'Create Association' wizard appears -> In the 'Name' stop, Give Name for the Association, select/give package for the Association. The Association Name is generally follows the convention <SourceEO>To<DestinationEO>. E.g., DeptEOToEmpEO.

3. Click 'Next' -> In the 'Entity Objects' section, select the Source and Destination EOs and the attributes in Source and Destination EOs on which you want define the association.

4. Click 'Next' -> In the 'Assocation Properties' section, specify the properties if applies. For e.g., if the assocation is composite, check the box 'Composite Association'.

5. Click 'Next' -> In the 'Edit Assocation Query' section, verify if the where clause for the association generated is right. You can modify the query where clause if needed.

6. Click 'Next' -> 'Summary' displays the summary of the created association -> Click 'Finish'.

7. Now, you'll find the newly created Association in model project under the specified package.

8. Once, you create the association between EmpEO and DeptEO, Jdeveloper will add the association accessors in each of the EOs.

Wednesday, September 8, 2010

ADF Model: Creating Entity Object (EO)

ADF Entity Object (EO) is created based on database table. To create an entity object, follow the below steps:

1. Right click on your model project and select 'New'. Alternatively, you can select 'New Entity Object' right clicking the package name.

2. 'New Gallery' window opens -> Search for Entity Object -> Select 'Entity Object' and click 'OK'.

3. If the database connection is not yet defined, it'll open 'Initialize Business Components' wizard -> Click on '+' and it'll open 'Create Database Connection' window -> Give your database settings -> 'Test Connection' -> Click 'OK' when the connection is success.

4. It'll select the created DB to create all business components.

5. Now, 'Create Entity Object' wizard appears -> In the 'Name' stop, Give Name for the EO, select/give package for the EO. And, you can browse for existing schema objects by clicking on 'Browse..' and then search and select the DB table.

6. Click 'Next' -> The 'Attributes' section displays the all columns in the table selected and they'll become the EO attributes.

7. Click 'Next' -> In the 'Attribute Settings', you can give properties for your EO attributes. At least one column should be primary key (I selected EmpNo). Otherwise, it'll ask to have RowID as the Primary Key.

8. Click 'Next' -> The 'Java' section is for generating Java Impl files for EO. Click 'Next' -> You can optionally generate default View Object (VO) and Application Module (AM) for the EO.

9. Click 'Next' -> 'Summary' displays the summary of EO -> Click 'Finish'.

10. Now, you'll find the newly created EO in model project under the specified package.

Tuesday, September 7, 2010

How to Create ADF (Fusion) Web Application

Creating ADF web application is easy. Just follow the below steps to start with.

1. Open Jdeveloper -> Select 'Default Role' in 'Select Role' dialog -> It'll open the Jdeveloper in default perspective/layout

2. The default Jdeveloper layout will contain 'Application Navigator', 'Structure' and Editor work area and 'Tip of the Day'.

3. Now select 'New Application' from Application Navigator

4. In the 'Create Fusion Web Application' window, give Application Name, Directory in which you want to create the application and then default package prefix which the Jdeveloper takes as the default package for all ADF objects in the application.

5. For any ADF application, you generally have minimum two projects namely 'Model' and 'ViewController'. Give the Name and default package prefix for these projects in the next stops in the same window. And, Jdeveloper will select the required technologies for Model and ViewController projects by default and if you want to add more technologies to your project, you can shuffle them in the settings.

6. Now, after giving all details, click on 'Finish' and it'll create the new application and you'll see it in application navigator.

Sunday, September 5, 2010

Introduction to Oracle ADF

Now, lets start with some basic introduction about ADF. Before that, for those who are familiar with Struts framework, we'll do a little comparison of ADF with struts.

Struts vs Oracle ADF

Similarities:
First thing is that both Struts and ADF are frameworks. Both of them use MVC (Model-View-Controller) architecture. Detailed ADF architecture is documented here. And as struts has it's own config file struts-config.xml, ADF has the config file called adfc-config.xml. As Struts has it's own framework API classes, ADF has it's own framework classes and API.

Differences:
Struts doesn't have any support for declarative development whereas ADF has support for declarative development. Struts doesn't have it's own components to use in development whereas ADF comes with it's own Oracle ADF faces components. Struts doesn't have any default persistence mechanism (i.e., default ORM) where as ADF has default persistence mechanism if we use ADF business components.

How to understand or get an idea about ADF as a new-bee?
Easy. Assume yourself understanding some database concepts. As you might be already familiar with DB concepts, it'd be a better idea to understand ADF concepts from DB perspective.

Before going into the details, ADF has some terminology you would need to know. I'm comparing the Database objects with ADF objects.

1. Database Table vs. Entity Object (EO): Both are analogous to each other. i.e., the entity object is built on top of Database table and it contains the table columns as attributes. And the entity object will inherit the database constraints as the attribute level validations. Examples of attribute level validations are given below:

Eg., if the column 'EmpName' in Emp table is 'Not Null', then the attribute 'EmpName' is marked as 'mandatory' by default and it'll fire mandatory field validation if you're trying to create Emp record without providing 'EmpName'. Similarly if you give the EmpName column as 50 characters, Entity object will have a precision validation for the attribute and will allow to enter only 50 characters. The same will apply for numeric data type columns as well.

That said, you don't need to rewrite your validations for default database constraints. You'll get them into entity objects by default.

2. Database View vs. View Object (VO): Again both of them are analogous to each other. You'll define a database view on top of multiple tables (which is basically a query join of multiple tables). Similarly ADF View Object is actually based on multiple Entity Objects. And, when you join multiple tables, generally you'll join them based on some foreign key. The same applies to View Objects as well.

3. Foreign Keys relationships vs. Entity Associations: Both of these things are analogous to each other. We'll define associations between entity objects based on the foreign key attriutes. Based on these associations, the join condition in View Object where clause will be generated automatically when the view is based on the Entity Objects having associations.

4. SQL Queries vs. Application Module (AM) operations: Any application would generally have four requirements. They are Search, Create, Update and Delete. I'm giving the simple example that uses SQL queries to perform these operations.

Let us take simple example of Employee-Department (Emp-Dept) tables of SCOTT schema. Now with just basic DB knowledge, how will you accomplish the above mentioned four operations for Emp table? I'll assume you'll give the following answers.

1. Search: You'll write a simple SQL query to query the database with where clause that corresponds your search criteria. For e.g., you'll write the below query to retrieve the employees list whose name starts with letter 'M':

select * from emp where ename like 'M%';

2. Create: To create a new Emp record, you'll write an SQL 'insert' query with the values for the new Emp record.

3. Update: To update an existing Emp record, you'll again write an SQL 'update' query with the 'where' condition matching which record has to be updated.

4. Delete: Similarly to delete an existing Emp record, you'll write an SQL 'delete' query with the 'where' condition matching which record to be deleted.

Finally coming to ADF, we'll add the ADF View Objects to something called Application Module (AM) which is a runnable instance. We'll be able to perform all of the above mentioned operations (like Search, Create, Update and Delete) via Application Module can do operations declaratively.

We'll see all of the above mentioned ADF objects and their implementation in detail in coming posts. So, stay tuned :)

Getting started with Oracle ADF

Hi all,

Oracle ADF is an evolving technology and many of the web application developers are tend to learn and use it in practice. So, for the purpose of new learners, I'm about to start a step-by-step tutorial of what is Oracle ADF technology and how easily and efficiently we can use it to build our next generation web applications.

Please note that I'm not going to copy-paste the content from Oracle ADF developer guide. I'm just going to write my understanding of ADF based on my experience working with it for about more than 3years. Having said that I can't be 100% sure that each line I write should be correct. Or, there might be a better way of accomplishing a task than the way I followed in here. So, if anybody has any suggestions or feedback, you're always welcome to write in comments.

Lets start now with answers to some basic questions.

What is Oracle ADF?
ADF stands for 'Applications Development Framework' and it's developed by Oracle. ADF is a framework and it'll help you build your applications easily as many of the redundant things that we do while we develop our applications are taken care by the framework.

How ADF is different from JSF?
ADF comes with ADF business components which are not available with JSF. You can develop an application using ADF mostly declaratively (drag and drop) and with very minimal java coding. The Java code we write in ADF application mainly uses the Framework's API. ADF mainly uses ADF faces components in the development. The main advantage of ADF is that we can blend any technology with it. For example, you don't need to have ADF business components in your model, you can have plain java code or EJBs as well. So, we can also use other components like JSF Core, JSF HTML and Trinidad components in ADF web application.

Coming to JSF, we need to have our entire business logic in java code. And, the java and there won't be any internal predefined business components in JSF. Even though you can use JSF declaratively, you need to bind the JSF components manually with bean properties. And, JSF mainly uses the JSF Core and JSF HTML and Rich Faces components in the development.

What is Oracle Fusion Middleware?
Oracle Fusion Middleware is the platform that provides various capabilities to develop, deploy and test enterprise business applications. It has a sound architecture that supports different technologies at a single point. Oracle says it's build with the 4 unique design principles 'Complete Integrated Hot-Pluggable and Best of Breed'.

Oracle JDeveloper 11g (11.1.1.3.0) is the latest version available and the same can be download from here. Check this link occasionally as the versions will be updated frequently. And, latest version means more features and less bugs in the software. Oracle Jdeveloper includes IDE(Integrated Development Environment) along with Database Navigator and Weblogic Application Server along with several other tools that help smooth and easy application development.

With this basic introduction, we'll dive into the development of Oracle ADF Web Application in the next posts.

Stay tuned :)

Thanks,
Murali.
Related Posts with Thumbnails