In the last post, I had walked you through the creation of simple ADF webservice which is based on the Departments table in XE database.There was no validation on the create or update method of the webservice in the previous version.There is a lot of chance that the caller of this webservice may send some junk data into your system through the webservice which doesn’t handle the validations properly.I have a lot of experience with my clients on this aspect :).
Also, the caller won’t know the ids in our system and most probably they will send the names(For Ex: Location id will not be known to the callers but they will know the Location Name).Instead of writing code to handle this kind of scenario, you can simply handle it by attaching the lov to the location id attribute.But this is tricky because locationid attribute is bigdecimal but how the caller will send the location name which is a string ??
Let me show the trick :)
First let us checkout the previous project from code.adfapps.com and build on top of it.
Step 1: Please verify that you have checked out the right project
Step 2: Create an lov vo based on the locations table.
Step 3 : Lets attach the lov to the VO Attribute, but we should not attach it to the Location ID attribute.Instead we should attach it to the new attribute called Location Name which is a calculated attribute.
Step 4: Once LOV is added to the Location name attribute, we can test our webservice by calling the updateDepartment method and pass the location name instead of the location id to verify the validated update to location id attribute.
Note: Don’t forget to set the Location name attribute’s updatable property to “Always”
It took some time to figure out this simple solution to handle list validation in ADF webservices.As usual, you can check out the code from code.adfapps.com website from the below url.
Tag Name in SVN : WEBSERVICES_LOV_VALIDATION