Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Saturday, May 26, 2012

Work Around: Detail Table in ADF Pop Up Region not refreshed at runtime as it caches old data.


While developing a simple master detail application in ADF I came across this problem. My model structure is as follows. I have a JOB table having structure like [JOB_ID,JOB_TITLE,MAXSALARY,MINSALARY] an EMPLOYEES table having structure like[EMPLOYEE_ID,FIRST_NAME,LAST_NAME,EMAIL,PHONE_NUMBER,HIRE_DATE,JOB_ID,SALARY ,COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID].
My view query is like below
image
In below Picture ADF popup ‘Employee List by Job Title’ gives the UI representation of the above view. And the Master table UI represents the JOB table. When user clicks on a particular row in master table, ADF popup shows all Employees having that particular JOB_TITLE. As shown in below picture
image
So far we are good and page renders properly and while user clicks on a particular row then Pop UP shows expected employee details . But the problem comes as user clicks on another row then Pop UP shows old data instead of new data i.e when user clicks on ‘Accountant’ row then it shows all EMPLOYEES who are ‘Accountant’. But when user clicks on ‘Programmer’ then also it shows all EMPLOYEES  who are ‘Accountant’ instead of ‘Programmer’.
My bean code is as follows



My Application module implementation code is as follows


Work Around:
After investigating a bit when I see the log file I am bit surprised, It is actually executing the view but the Pop Up is not able to show the updated data.

image As a work around I have used partial target programmatically while user closes the pop up. And it solves the problem.

Code for Pop up is as follows



Here “d1” is document id used in UI page.

Sunday, October 30, 2011

Work Around: Popup forces user to enter required values first

 

In my previous project I came across a typical problem While trying to enter value using pop up. The problem is If other required fields on same page are not entered and button/link for generating popup pressed , then an error message appears like below. It forces us to enter required values first.

image

As a work around I have used the option [immediate=true] for the button/link responsible for the pop up to be generated. Please follow below snap shot. Earlier command link selectText has no option set as [immediate=true] and we get above error.

image

After setting the option [immediate=true] for the command link selectText, above error resolved as we redeploy it.

image

Below screen shows that all required fields are empty but it is not prompting us to enter required fields while trying to open popup as user can enter data successfully in pop up and no restriction comes from required fields.

image

Saturday, October 29, 2011

Field Validation in ADF as user Tab out

In this blog I am trying to show validation as user tab out any field in ADF. User enter data in a form field and as he tab out the field validation happens and If validation criteria does not meet error message appears.

image

An ADF application has model and ViewController project. We can create the form in ViewController project. Please follow my previous blogs for the basics of Form generation in ViewController project. So rather than spending much time on the basics like Form generation , I would like to show special things I have done here to accomplish above goal.

Step1: Create a java class and implement javax.faces.validator.Validator,java.io.Serializable. Implementation of Validator will ask for the validate(FacesContext facesContext, UIComponent uiComponent,Object object) method to be Implemented. Here I have created a java class named EmailValidator. This java file can be downloaded from http://www.box.net/shared/cux283rmjp45cl8mry2x link. Similarly we can create another java file for date validation. Please download the same from http://www.box.net/shared/trtvicb7ihesdmy6hpzx link.

Step2: Declare these java files as validator in faces-config.xml file. Please refer below snapshot

image 

Step3: Modify your form so that it will not obey default validator and follow the custom validator you have created in step2. Please follow below entry in your jsff file.

image

Please download the jsff file from below link http://www.box.net/shared/8eb7hcm4qxq0330n3eme

Please deploy and it will work as expected.

image