I write solutions to the problems I can't find much about elsewhere on the Web, also some code/script snippets that are absolutely awesome and make my life easier. Will be glad if someone finds these posts interesting and helpful!

Monday, May 3, 2010

Global validation for a Date input field in ADF 10

Say you have a table with a date column and you have created a view accessing it. Now try to insert an abnormal date into the dateInput field on the page (something like 1/1/111111111), commit the changes, check the value in the DB and you’ll get what I’m talking about here. I had queried a question on the OTN forum regarding this and the only answer I got was from Frank Nimphius to
configure a value change listener on the date field and verify that the provided value is valid, If not call FacesContext.renderResponse to ignore the request
this is a solution, but well, it requires more or less to apply it to each dateInput field on every single page. The other way around that I finally used, was to override the EntityImpl setAttributeInternal method like the following:

which actually just checks that the Date attribute provided is of a logical range.

This method has to be part of a class extending oracle.jbo.server.EntityImpl and obviously the entity implementation for that table with a date column must extend the new EntityImpl class.

That's it. Hope this helps!

No comments:

Post a Comment