Tuesday 7 May 2013

ADF : To implement duplicate record validation form Entity Object (EO)

Most of the time we need to make sure that no duplicate value should exist in database. For example you are making an entry in the employees table in HR schema you dont want that no two employees have same First name. So, in ADF you can eaisly implement this validation. You just have to put an integrity constraint in the EO and simply give the message that you want to show when the user enters duplicate employee name.

  1. Create a Fusion Web Application(ADF) in JDeveloper. And create connection to the database. And then create a taskflow and then drag an view from component pallate and then give it a name and create a jsff page.
  2. Then right click on the model and then create business components from tables. And then select the employee table and create VO and EO and add the same in AM.
  3. Now select EmployeeEO and in "General" tab add an alternate key with "First Name" column, then go to "Business Components". And then select "Entity Validators" and click on Add button. And choose Unique key in "Rule Definetion". Then go to the another tab in the popup "Failure handeling" and write the message that you want to show when duplicate record is found.


  4. Then just go to the jsff page and then then create a form from the table that comes shows in Datacontrol. Then just add "createInsert" and "commit" button from the operations in datacontrol.
  5. Then create a jspx page in viewController and drag the taskflow in it and right click and run the page. Click on createInsert button and enter a name in First Name that already exists and then click Commit. Then the error will come up at First name field.


    You can download sample app here. DuplicateRecordCheck.rar
    Simply download and unrar it and the run it in JDeveloper.

1 comment:

  1. Hi,
    Is it possible to do this in bean code for commit button.
    If yes suggest me code pls

    Thanks

    ReplyDelete