Monday, March 8, 2010

Moving to Jdeveloper11g Your First ADF Form

Hi all,

As you may know that i m playing with Oracle ADF and recently i have completed my First sample ADF application called TUHRA 2.0 following the steps from the Jdeveloper Handbook which is good book to start with (don't afraid of 600 pages of theory in the start before u to actually develop something) :)

So if u also want to learn something new then don't worry here is your first step.

In this Post we will create basic ADF form which is based of Oracle default HR schema's Table Employee later posts i will enhance this form by some LOVs and other stuff. At the end you can also download my completed example

Pre-requisites:
- Download and Install Jdeveloper11g from OTN Website
- Create default HR schema in Oracle database

Creating Application and Entity Objects:

- Open Jdeveloper Choose default role if asking.

- Choose New Application from  Menu

- Enter Application Name "MyFistJSF" Application Package "adf.demo" and Select Fusion Web Application ADF in Application Template



- Create Connection in Application Resource Section on the left pane named as "HrConn" and Test connection it should appear Success



- Click Right on Model Project choose NEW select Business Components from Tables Click OK as shown in the slide


- By Default HRConn Connection will appear Click OK and choose the Employee table to selected area set the Package name to "adf.demo.model.entities"

Click Next and skip all steps up to Application Module


- Named Application Module as HrModule and package to "adf.demo.model.services" click Finish



This process will create the Employee Entity with Application Module in the Model Project



Creating View Object based on Employee Entities:

- Click Right and choose New on Model Project Choose View Object and Click OK

- Enter View Object Name EmployeeVO change package name to "adf.demo.model.view" click Next

- Choose Employee entity to selected area like in the slide  make sure updatable check is selected

- Choose all Fields to selected area as in the slide

Click Finish Now your Model Project is ready to create Your First ADF page


Linking View Object with Application Module service:

- In order to set which service to Use at run-time you must link your View objects in the data model.

- Open HrModule under "adf.demo.model.services" section in Model project and go to Data Model Page

- Select EmployeeVO on the Available pane Change the name at the Bottom New View Instance to "EmployeeVO" and move it to Data model side under HrModule Page should looks like this

- Save all

Creating JSF page:

- Double click adfc-config under Page Flow directory in ViewController Project
- Drop View Activity from component palette named it "employee"



- Double click the "employee" view activity select Blank Page click OK leave others as defaults



- Jdeveloper will open one default layout.

- Expand Data Controls section on the left side select "EmployeeVO"
- Drag and drop it to employee.jspx page and Choose ADF > ADF Form from the Menu




- Select all fields as shown in the slide and check Include Submit Button and Navigation Controls Click OK



- Your form should appear like this



- In the structure window in Warning sections right click on "prefix h is never used in the document" and choose remove as shown in the slide



- Click in the structure pane the af:document and set the Title property on the right side the to Employee Form (To remove the 2nd Warning)



- Save all and Right click to Choose Run on employee page

- If you got error similar to this means Jdeveloper created wrong Association between entities (Sometimes it is too helpful :) )



- Go to Model project and expand adf.demo.model.entities package and right click and choose Delete  "EmployeesEmployeesFkAssoc"  association is not for us.

- Save and Run the form again You should see the form in the browser similar to this

- If you got Timezone error then make sure timezone is set in Jdeveloper projects
check how to set timezone


Thats all for this Post hope it is helpful for who are just coming into Oracle ADF world.

You can download my completed example from here

Check JDeveloper Handbook and Fusion Developer guide as well

















Cheers,
Baig

5 comments:

  1. Hi Baig,

    it is very nice article for newbees like me in ADF field.
    i have created page but while running im not getting any errors and output page is not shown.
    Can u plz tel me where i went wrong?
    how to resolve this issue?

    Regards,
    Raja.

    ReplyDelete
  2. Hi Raja,

    Sorry for late response being busy for last few weeks..

    You can check the log file what error you are getting. If you are experiencing Timezone not found error then search this blog for solution.

    ZB

    ReplyDelete
  3. i try this it work fine with me - i get mew thing
    Raja i thing you have to wait WebLogic server to generate the page it take time

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Hi Baig,
    Thanks for the post. I done all the above steps.
    But am getting the below error if i run the employee page i am getting this error "he Server Instance cannot be started because the Integrated Weblogic domain was not built successfully."
    please help me on this Thank you.
    Regards,
    Kotresh

    ReplyDelete