Sunday, March 21, 2010

How to Create ADF LOV with Filter or View Criteria

Hi all,

This week i will continue my last post about Creating LOV in ADF application and today i will create LOV on ManagerId Column which is different cause of 2 reasons

We would add following 2 business rules to the LOV

1) Manager cannot manage themselves i.e ( EmployeeId <> CurrentEmployeeId)
AND
2) Employee can be manage by other employees in the same department or in Executive Department which ID is 90.
(DepartmentId = 90 OR (DepartmentId = CurrentDepartmentId)

For this we have to create a View Criteria on our ViewObject (VO) that will filter the list based on few Bind Variables.

Steps:
Creating View Object (VO):


- Create new VO in adf.demo.model.queries package called EmpManagerLOV based on Employee entity with updateable is deselected.

- On Attribute page choose DepartmentId, EmployeeId, FirstName and LastName on Query page choose Order by as FirstName and LastName.


Adding Bind Variables to VO:

- Double click the VO EmpManagerLOV go to Query tab page in the Bind Variables section click the green + sign and Create 2 bind variables.
- Name CurrentEmployeeId Type Number Required No
- Name CurrentDepartmentId Type Number Required No





Creating View Criteria:

- In View Criteria click Add Button (Green + sign)

- Enter the Criteria Name as "EmpManagerLOVCriteria" click the Add Item button along with Group and choose the settings as shown in the slide to complete the 1st Rule required (EmployeeId <> CurrentEmployeeId)



- To add 2nd Rule i.e (Department = 90 and DepartmentId = CurrentDepartmentId) Follow these steps
select the top-level node (EmpManagerLOVCriteria) and click Add Group button and select new group node and set the Conjunction as “AND”.

- Click Add Item and set the expression as “DepartmentId = 90” with a Validation of
“Required.” Operand set as “Literal” in this case.

- Select the “AND Group” node and click Add Item again. set all fields as shown in the slide.



- Click OK

- Your screen would look like as in the slide

Creating LOV:

- Double click the EmployeeVO in attributes page click on the ManagerId and In List of Values Section click Add + button

- Add a List Data Source item, and select “EmpManagerLOV.”
Change the Name to “EmpManagerLOVAccessor” and move it to the View Accessors
area.


- Select the EmpManagerLOVAccessor and press Edit on the Top

- Move the EmpManagerLOVCriteria to the Selected area.

- In the Bind Variables section double click the value section and enter both values for both Variables as

For CurrentDepartmentId  enter DepartmentId
For CurrentEmployeeId enter EmployeeId


Click OK and Rest you can follow same steps as in my last post or just follow slides.
- Set LOV Configuration as in the slide
- Go to UI Hints and set following settings
- Go to Employee.jspx page delete ManagerId field Drag and Drop ManagerId from Data Control and choose List of Values > ADF LOV Choice List


- Your Design Page would be like this

- Right click and Choose Run on Employee.jspx page  you will see something similar to this click Manager ID LOV item

- Press Search link appearing in the LOV ADF will open a pop to display all values. You can filter your values and press OK

Thats all for today

You can Download my completed example

Dont forget to check these 2 amazing Books about ADF































Happy Learning,
Baig

17 comments:

  1. Thanks For your examples very ggod work

    ReplyDelete
  2. hello sir ,
    i just want to know can we add LOV in view criteria??

    ReplyDelete
    Replies
    1. Hi,

      Yes you can do this. You need to set the attribute type as List in ViewObject google it you will find many examples http://docs.oracle.com/cd/E21764_01/web.1111/b31974/web_search_bc.htm#autoId6

      Zeeshan

      Delete
  3. Hello Zeeshan Bhai,

    i am sorry, but now whenever i search google for some problem and i see solution provided by you, i simply ignore it. why? because your blogs (no doubt the special blogs) are only for experts, i mean begginners cannot benifit from your blogs. simply, your blogs are not step by step. i know you may be a very busy guy and have no time for writing something step by step even in your videos i noticed the same thing. this is just to inform you. by the way, i am proud on you that somebody from our continent is that much expert.
    thanks
    thanks.

    ReplyDelete
    Replies
    1. Hi Khattak,

      Thanks for your comments. My posts are about specific topics or problems that you fix in real world and sometimes they are not covered in any training or course. if you read the title of the post you will understand.

      If you want to learn about technology then you should read the product documentation not blogs.

      Hope it helps,
      Zeeshan

      Delete
  4. Hi Zeeshan,

    Thanks for providing insight on LOV's in ADF. I just need your suggestion on something related to LOV if you might came across this scenario as part of business requirement.

    Use case is that there have to be 3 LOV's on the form and data is being pulled from 3 different tables for each of the LOV where tables have no relation.
    First LOV(Select one radio) will display list of Currencies(USD, GBP, EUR etc),
    2nd LOV (Select one radio) will display list of Customer Type(Individual, Corporate)
    3rd LOV (Select one Radio) should display value from 3rd table in database based on combination of first two.

    For example, if I select USD in first LOV and Indidivdual in 2nd LOV then 3rd LOV will give something like USD4ME, USD4NO etc which is coming from separate table which has no relation two first two tables, but value of first and second LOV is present in 3rd table.

    Could you throw some light on this, how to acheive this result in ADF Web application.

    ReplyDelete
    Replies
    1. Hi,

      Sorry for late response...you need to create dependent list of values. google it you will find many examples here is one for you https://blogs.oracle.com/aramamoo/entry/how_to_create_multi_level

      Zeeshan

      Delete
    2. Hi, how can you make the following improvement: displaying in ManagerId not the ID, but managers Name after selecting from LOV?

      Delete
    3. Hi,

      Change the view attribute in the LOV properties on first tab of Create LOV wizard

      Regards,
      Z

      Delete
  5. this option is not found in 12 c

    ReplyDelete
    Replies
    1. What option? can you provide more detail ?

      Zeeshan

      Delete
    2. The option foe editiing view accessors and apply a view criteria when creating a LOV,

      Delete
    3. Hello,

      Actually this option still exists in 12c, however in a different location. After you set the LOV for your view object attribute, and then go to the 'Accessors' tab. There, you can modify/edit the View accessors, and add the parameter to the LOV you're using.

      Delete
  6. Hi Zeeshan,
    In the lov , once you click on "search", the search region opens up with managerid and employeeid.
    They appear as they are the bind conditions in the view criteria.

    How can we ensure that the LOV does get filtered on the managerid and employeeid, but the id fields should not appear in the lov search region.
    A user may not want to see id columns in the search region.

    ReplyDelete
  7. If this LOV is based on a view criteria. You can hide the particular bind variable for that field (on your case it's managedid and employeeid). So what you should do is go to the query tab of the source View Object, then edit the bind variable. On Bind Variable window, go to control hints tab, then set the display hint to hide. This will hide the field of a view criteria from showing on the Search Region of the LOV.

    ReplyDelete
  8. Hi,

    Post is impressive, I followed this to implement one of the case in our application.

    We are facing issue with the combobox, its not editable is first thing, when i remove the value then its editable but, dropdown values are not shown/loaded.

    We are using jdev 11.1.1.9.0 version for this.

    Please help in this regard.

    Thanks.

    ReplyDelete