Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Thursday, 20 June 2013

ADF : Refresh issues in Oracle ADF Application

During the application development in ADF, the most common problem that we encounter when our application is deployed on server is the problem of refresh. That means you expect a component to refresh on some action but still it doesn't happens.

This problem comes into picture in a big size application that uses many other applications or many taskflows are being called into it.I dont exaclty know why this problem comes into focus, but its some kind of 'id' problem of UIcomponent. 

So, here are some of the solution if the above problem comes into picture.


  1. The easiest way to give partial trigger to a UIComponent is to go into the properties menu in the property inspector and simply choose the component id you want to select. So whenever the selected UIcomponents will have a change, the UIComponent on which partial refresh is given is refreshed.



     
  2. Sometimes it happens that even after giving partial trigger on the UIComponent the Component is not been refreshed.So, you can try to refresh the component from the bean using java code.
    AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponent);


    Here 'UIComponent' is the binding of the UIComponent on the page into the bean.
  3. Sometimes the above two methods fail.After using the above two techniques also the field is not being refreshed. Then you can use the ResetUtil class for resetting the fields.

    For using ResetUtil you have to import the given class:
    import oracle.adf.view.rich.util.ResetUtils;
    

    And to use it on the page :

    ResetUtils.reset(UIComponent); 
      
  4. After using the above methods if Still the problem exists. Then if you are using model in your application, then you have to perform "execute" on the used ViewObject.
  5. Still if the problem persists, then perform "Rollback" after the "Commit" operation.
  6. Still if the problem exists, please drop your case in the comment box.. :) 

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.