Thursday, February 11, 2010

New Cascading LOV with required View Criterion Not a Bug

On july 2009 in the patch of jdeveloper (11.1.1.1.0) a new feature was introduced in view criteria. When a criterion is required then an error message is shown to user. Of course not without side-effects (http://adfbugs.blogspot.com/2009/07/query-component-required-criterion-bug.html)
On the latest patch of jdeveloper (11.1.1.2.0) a new feature and bugs was introduced in view criteria (http://adfbugs.blogspot.com/2010/01/new-bind-variable-and-view-criteria-bug.html)
The above bugs also effected the functionality of LOVs especially of those that use view criteria, either for selective required (http://adfbugs.blogspot.com/2010/01/selectively-required-criteria-in-lov.html) or for cascading LOVs.

In the current test case I have Employees and I want the List of value of Managers to depend on the department of the employee. I expect when the user has not selected a department the List of values of managers to be empty



Yet when I run application, just when I set department to null I get the following error.

ADF: Adding the following JSF error message: Attribute DepartmentId is required.
oracle.jbo.AttrValException: JBO-27035: Attribute DepartmentId is required.
at oracle.jbo.rules.JboVCItemRequiredValidator.validateItem(JboVCItemRequiredValidator.java:91)
at oracle.jbo.rules.JboVCItemRequiredValidator.validate(JboVCItemRequiredValidator.java:161)
at oracle.jbo.common.ViewCriteriaImpl.validateRow(ViewCriteriaImpl.java:606)
at oracle.jbo.common.ViewCriteriaImpl.validate(ViewCriteriaImpl.java:567)
at oracle.jbo.server.ViewRowSetImpl.validateViewCriteria(ViewRowSetImpl.java:7745)
User will think that DepartmentId is required, yet only the hidden criterion of LOV is required.


But actually it is just a warning, since if I press ok and submit then the new values are submitted, even though the value of ManagerId is not valid.

If I open ManagerLOV I get again the error and the LOV opens with no data.



If I clear the value of Manager I get the error again.

This is realy confusing and makes view criteria not usable in cascading LOVs.

The workaround we do for these cases is not to use view criteria for cascading LOVs but to put conditions directly in the where clause of the query.
i.e. WHERE DEPARTMENT_ID = :inDepId

Test Case
http://adfbugs.googlecode.com/files/TestLOVwithRequiredCriterion.zip

Thanks,
Anonymous said... In this case, all you need is to set "Validation" to "Optional" and leave "Ignore Null Values" un-checked.

I tried it and works fine.

5 comments:

  1. I think its just a wrongly-defined use case:

    If you need the DepartmentId required, do not give the option of "Include "No Selection" Item" in the LOV_DepartmentId. Otherwise, set "Validation" to "Optional" and "Ignore Null Values" checked in the ManagersLOVCriteria.

    ReplyDelete
  2. The use case is this

    Department and manager of Employee should be optional,
    Manager of the Employee must be of the same department.
    So when Employee has no department then Managers LOV should be empty.

    I think its a common use case.

    ReplyDelete
  3. In this case, all you need is to set "Validation" to "Optional" and leave "Ignore Null Values" un-checked.

    ReplyDelete
  4. You are right. Thanks for your contribution, i will update this as Not a bug.

    ReplyDelete
  5. Yes correct , i did the same and it did not created a issue for me.

    I selected made deptname , dept id as 'selectively required' and managed_id as optional with ignore null value unchecked.first time managed id drop down will be blank.

    if i dont give any value it gives exception 'one of field is required' ,then i select dept_id , managed_id dropdown will dynamically change based on dependent LOV setting.

    Question: I want to overide the af:query message 'atleast one field required' to something else.

    ReplyDelete