When you create a component in ADF , whether its Entity object or a view object in the model layer, or drag and drop view object on the jsf page, there are many xml files and other files which are created by Jdeveloper. And developers gets crazy as, why so many files are created and what are they for. Specially beginners/ADF newbies gets confused with so many xml files which getting created, and that gives them one reason to run way from learning ADF. In this post I will try to explain these xml and other files which you should know as a developer when you do development using ADF.
When you create an application in Jdeveloper with “JSF , ADF BC” as template, two project gets created “Model” and “ViewController”. And a file
1) .jws which is used for storing the projects added in the workspace(check your workspace on disk).
Under the Model and ViewController projects two files gets created as “Model.jpr” and “ViewController.jpr”.
2) .jpr file is used to store the project related information like java files created in the project etc.
3) Model.jpx file contains all the application modules defined in your Model project. And other configuration details such as database connection used in model layer. Some times during development, if you get “JBO 30003” or database error, then check the “_NamedConnection” parameter in the same file, if it is pointing to the correct database connection name.
4)EntityName.xml (for EmpEO, it is EmpEO.xml):- This file contains the name of the database table from which the entity object is created, name and data type of each attribute in eneity object, and the corresponding column to which that attribute represents. For example in the following figure, attribute “EmployeeId” is driven from the column name “Employee_ID”, with type as number and other attributes such as primary key etc:-
5) EntityNameImpl.java(for EmpEO, it is EmpEoImpl.java):- though it is not required to generate this file, as default option it is created. It has getter and setter methods for the entity object attributes. This file can be used to add custom code, such as in the setter method of commission of the employee, commission can be first calculated based on the employee salary, hire date or other conditions.
View object fetch the result set from the database based on the query on which it is based. Once you create view object whether entity based or read only,two files are created:-
6) ViewObjectName.xml(for EmpVO, it is EmpVO.xml):-which specifies the entity object on which this view object is dependent, query of the view object which will fetch the desired resultset and the attributes which are there in view object.View object is created at run time based on this .xml file.
7)ViewObjectNameImpl.java(For EmpVO, it is EmpVOImpl.java):- When ever you create a new row in the view object, and you want to provide some custom behavior when a new row is created, you can overwrite create() method in same class. Similarly remove() and other methods.
An Application module which acts a container for view objects and take care of transaction handling. When you create an application module, two files are create:-
→ iterating two or more view objects result set added in same application module to perform some business logic.
→ calling a pl/sql code.
→ writing a method and later on exposing it by adding it in client interface, so that it can be called from view layer.
10) Bc4j.xcfg:- it has different configuration properties of the application module, as such , the name of the database connection, type of DB connection etc.
Once you create your jspx page with drag and drop any view object from data control palette, page definition file and DataBindings.cpx file gets created.
11) DataBindings.cpx:- This file is created for the first time and only once when you drag and drop any view object or method from data control palette to the jspx page. This page contains information about page definition file corresponding to your jspx page, the data controls used by your application. Ya ya, I know you are now thinking of what is data control and data bindings. Thats actually what I am thinking of my next blog post topic :). Check the following figure, it shows the contents of the DataBindings.cpx file, when I drag and dropped the EmpVO from the data control palette to ViewEmpDetails.jspx page as ADF read only table. It shows how ViewEmpDetails.jspx file is linked to its page definition file ViewEmpDetailsPageDef.xml:-
Created DataBindings.cpx file is created under the view controller project → Application Sources → view .
12) PageDef.xml(for ViewEmpDetails.jspx, its ViewEmpDetailsPageDef.xml):- Page definition file created for each jspx page,when you drop a particular component from data control palette to your jspx page. This is the file which actually wries your UI components to the corresponding attributes in the view object. This file mainly contains following elements(tags):-
12.1 ) executables:- which defines various result sets(specified as iterator tag) to be executed when the page is loaded. Or defines the methods exposed from application module in client tier(specified as methodIterator tag) to be executed.
12.2) bindings:- it specifies the attributes which will be contained in the result set pointed by the iterator tag. Or the details of method to be executed pointed by the methodIterator tag.
Check the following figure, in which iterator EmpVO1Iterator specifies the employee details to be fetched when page is loaded. And under bindings it specifies all attributes which will be available in the result set to be shown in UI.
If you check the source of the ViewEmpDetails.jspx page, it will be clear to you that how it is wired to the elements present in the page definition.
And at last two files which are created by Jdeveloper itself under web-inf folder in ViewController project once you have create an application with “JSF , ADF BC” as template are:-
13)faces-config.xml:- which acts as a controller by storing the navigations rules. And in addition to that it stores the configuration details about managed beans.
14)Web.xml :- which is the standard j2ee deployment description file and provide application level configuration details.
10 comments:
Good post! Just one note, something that's changed for 11g: By default, Java files for business component's *aren't* created any more. That includes #5, #7, and #9 above.
And I think this is important for people to remember about all the XML JDeveloper creates: don't think of it as being in addition to lots of Java classes, think of it as being *instead of* most of the Java classes. For most purposes, the, say, EO XML is doing the work of a Hibernate-mapped class--that's an extra XML file over Hibernate, but unless you really need an entity object class (and the reasons you might are fewer with each release), it's one less Java class than Hibernate. So the number of files more or less balances out.
Ditto page defs and backing bean classes: Because of page def files, most (almost all, I'd say, though certainly not quite all) pages won't *need* a specific backing bean class. So ~95% of binding XML files are in a 1-1 exchange with the Java classes they obviate the need for.
Thanks Avrom for sharing such useful info. in ADF
11g.
Vikram
Great post. Your descriptions are very simple to understand. For someone learning ADF it really helps when no detail is left unsaid.
now i got some more info abt ADF BC files.
but i have some more doubts in this can i ask to you..
please reply to me bharathiks246@gmail.com
It is rather interesting for me to read the blog. Thanks for it. I like such themes and anything connected to them. I would like to read more soon.
Excellent post, very clear and covered the basics.
Excellent post, very clear and covered the basics.
Excellent post, very clear and covered the basics.
Excellent post, very clear and covered the basics.
Excellent post, very clear and covered the basics.
Post a Comment