ADF 11, ADF BC
I might be missing something but how do you add a validator for an unique key ?
I have an unique key defined on the DB, this unique key has nothing to do with the primary key.
(Its checking that a code is unique)
In the validators on the entity object I can set an unique key validator but it only lists the
primary key for the check definition not the unique key....
The unique key on the DB is working as I get a nice constraint violation error, so how do I
either add a validator for a unique key or at least trap the error in order to display a user friendly message.
Go to the EO, open the attribute section and edit the attribute you want to be unique. In the dialog set the check mark on the Unique ceckbox and save your work.
This should insert a unique constraint for the attribute.
My recommendation would be to leave the unique constraint validation in the DB. Have a read of section 37.8.3 (updated for 11g, in 10g it's 33.8.3) of the Fusion Developer's Guide, where you will find out how to provide your own nice error messages instead of the ugly constraint violation one.
No worries. My top three suggestions for people using ADF, by the way, include:
1). Read the developer's guides (Fusion Developers Guide, Web User Interface Developers Guide)
2). Read them again
3). Go to 2.
Seriously, I generally scan the documents from cover-to-cover once or twice to get a feel for what is in there. I read each chapter through. Most of the information doesn't stick in my brain at all, some of it I conceptually understand but cannot see a use for yet, some of it is really useful, etc. Even for things in the first two categories (stuff that I don't really understand nor see the use for initially) - the fact that the information is there sticks in my brain - that way, when the time comes when I need the information, I usually vaguely remember that such a chapter exists and go hunting for it.
But i would like to display a custom message when any database table constraint is violated. I added a custom class which extends ListResourceBundle class. It helps to decode the JBO errors but not ORA errors. When any constraint is violated, it shows two error message (JBO and ORA). How to customize ORA message?
Read the post again: http://it.toolbox.com/blogs/jjflash-oracle-journal/reporting-ora20xxx-errors-with-adf-bc-the-details-33094 X-(
I created my own subclass of JboException so that I could override getProductCode and use my own product code instead of "JBO". It is very short, and not worth including here. The only thing I don't like about the way I've implemented this is that I use a constructor that does not use a Resource Bundle to localize the message. I'll probably change that later.