Thursday, November 27, 2008

Workaround for Null Value Bug in ADF List Of Values 11g

Those of you, who are using List Of Values (LOV) component in ADF 11g, most probably already have noticed bug related to Null value. Simple description - if any non Null value is set for LOV, it is impossible to set Null value (for non-mandatory LOV's). This bug is known for Oracle, and I'm sure they will fix it in next build. For now, there are two paths for us. First is to ignore it, and test with next build, when it will be available. Second is to apply temporal workaround, until bug will be fixed by Oracle. In my opinion, you should follow second path, if you have critical need to be able to set Null value for LOV before next build will be available from Oracle. In this post, I will describe this workaround, relatively very simple one.

You can download sample application, with implemented workaround - LOVNull.zip. This sample contains basic form, with one LOV component for DepartmentId attribute:


So, the problem is with Null value in LOV component, basically Null is not accepted. This bug is not related to the Model, because if you will test with ADF BC Browser, it works well. Bug is related to View layer. This means we can invoke exposed method in View object and set Null value for LOV attribute programmatically. To achieve this, I have created my custom method in View object class and exposed this method through Client Row interface:


Exposed custom method clearLOV(), basically invokes setter method for DepartmentId attribute and provides Null.

In View layer, for my LOV component, I have set AutoSubmit=true property and provided ValueChangeListener in order to check when user will try to provide Null value:


ValueChangeListener compares new LOV value to Null, and if user is trying to set Null, exposed custom method is invoked trough bindings to set Null value programmatically:


And how it works? Let me at first to show how it works without workaround. Here we have a form with LOV component, by default value is not set for LOV:


Let's set provide any non Null value:


And now, when LOV value is stored in database, let's try to clear it:


Press Save button to store our last change and you will get previous value back - Null (or empty) value is not accepted anymore:


However, if you will use described workaround, Null value will be set as expected:

3 comments:

  1. Thanks a lot for your post.

    ReplyDelete
  2. Hi Andrejus,

    I am not able to download the application, it seems URL not available.
    Can you post me the What do you have in ClearLOV() method. I have same issue, I need to handle in this way. But I have tried in ClearLOV() methd I sent to null my attribute value, still its throwing Stack overflow error exception.

    ReplyDelete
  3. Hi,

    I got the same errors in jdeveloper 12.2.1.2. Search for patch on support oracle without luck. Are this workaround still the only solution for 12.2.1.2?

    ReplyDelete