Sunday, November 20, 2011

Custom Exception Registration for ADF BC EO Attribute

Sometimes customers prefer to implement business logic validation completely in Java, without using ADF BC declarative/Groovy validation rules. Thats fine, we can code business logic validation in ADF and implement different custom validation methods on VO/EO level. How to report validation message from custom method on VO/EO level? We can throw JboException, but it shows up on UI as popup. When custom validation is implemented for specific attribute, we would like to attach validation message directly to the attribute itself. Steve Muench helped us this week with EO Attribute Exception registration, I would like to share solution with you.

Download sample application - This sample implements custom validation method on VO Row Impl class, means custom logic can be applied per row:

If validation logic fails, we are calling our own validation failure method implemented inside EO Impl class. This method actually constructs AttrValException and attaches it to specific attribute using standard registerAttributeException(...) method. Validation message is retrieved from Message bundle. On the UI AttrValException will be rendered the same as declarative attribute level validation message declared on EO attribute. See detail code for attaching AttrValException here:

Validation message will be retrieved from Message bundle:

In this example, just for demo purposes, validation is triggered in UI from separate Action Listener method - just by calling custom validation logic from VO Row Impl:

Validation messages shows up nicely, directly attached to the attribute field:


Anonymous said...

Very Cool.

I am new to ADF.
"Validation message will be retrieved from Message bundle:"

How do I do it?


Andrej Baranovskij said...

In this specific case, message is retrieved using such code:

If you have more detail question, please post on our public RedSamurai wiki:


Makrand Pare said...

Hi Andrejus,

Thanks a lot for the post. I tried your example in my program however the error message appears only after second click not on first click. I'm using JDev What could be the reason?


Ajith said...

Hi Andrejus,

Thank you very much for your post.

I have a clarification. We have a method validation in EO which is deferred to transaction level which actually checks whether one column in a table is empty or not. If in any of the rows, the value is null the validation will throw an error message. Please update whether we have any way to show an attribute highlighted error message in this case.

PS: we have clicktoedit enabled for this table

Mr.James said...

In Jdev, on the 1st click, it will work as you explained. However, on the 2nd click, ADF will throw an exception:

ADFc: No exception handler was found for an application exception.
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getHintObject(
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getHint(
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getLabel(
at oracle.adf.controller.faces.lifecycle.Utils.buildFacesMessage(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addMessage(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addError(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addError(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addError(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addError(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.addError(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.reportErrors(
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareRender(
at oracle.adf.controller.faces.lifecycle.FacesPageLifecycle.prepareRender(
at oracle.adf.controller.v2.lifecycle.Lifecycle$9.execute(

Andrej Baranovskij said...

This was tested with previous ADF releases, perhaps in some tweak is required. If I will have time, I will check it.


Anonymous said...


I am using 12.1.2. I face the same problem of null pointer exception in the second click. I see that you have mentioned some tweaking is required to get around this issue. can you share what that is.


Ashok Reddy Singam said...

Hi Andrejus,

I am using Facing same issues as others.
1)First click is not doing anything
2)Second click i see validation msg as expected
3)Third click below exception oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(

In case if you have any workaround to fix then please share with us