Search code examples
oracle-adf

Programmatically update the adf form


I'm learning Oracle ADF(11g). Please help me with the solution to this scenario:

  1. I would like to update few fields in a "af:panelFormLayout".
  2. For example, the fields I have in the form are: Employee, Department, and Salary.

enter image description here

  1. I would like to update the salary of all the employees of department '90' shown in the form. For this, I have added a check box with the label: Select All Employees, to the form. When the checkbox is selected, all the Employees of the department 90 should be updated with the salary mentioned in the form, else, only one employee 'Steven' salary should be updated. How do I achieve this programmatically?

Solution

  • One way to do this is to use the ValueChangeListener on the checkbox to call a method on a backing bean when the box is checked/unchecked. In the backing bean confirm the box was checked. If it was, then get a reference to the desired Data Control Iterator and then you can programatically iterate over the records in the VO/EO cache and change each salary. There are many links on the web for how to do this, e.g. here.

    That being said, I do question the usability of your design. I don't think it makes sense to have a checkbox in the middle of a single record that says "all employees". Can be very confusing for a user. Is that "ALL employees"?" No - just the ones in this department. I would have used a table for this then the check box makes more sense. But, if you MUST do it this way per user demand (questionable) at the very least I would move the check box away from the record and make it clear that the check box will set the salary to:____ for all employees of Dept: _______.