DEV Community

Cover image for orclapex 5.x page validations (upgraded concept)

orclapex 5.x page validations (upgraded concept)

isabolic99 profile image isabolic99 ・2 min read

First thing first, let me be clear this is observation post and some sort of solution approach. Last week I analyzed apex application which was created on apex 4.x and imported to apex 5. The application was imported successfully and I knew that I can't use universal theme features ( for example template options). Now for the interesting part and that is validation process/execution. This has changed in apex 5, but also for imported application it did not stayed in apex 4 "mode".
Here is the explanation:
In apex 4.x validation are rendered as html region after page is submitted but in apex 5 validation are actually applied by javascript. Before submitting page there is AJAX call that return JSON array with errors. Look at the example down below..

Example how it looks in apex 5:

Example how it looks in apex 4:

Now in our application which was build on apex 4 we hided validation region and displayed validation using jquery jgrowl plugin after page submit.

when we migrate to apex 5, message where not displayed, and reason is AJAX call..

<script type="text/javascript"> 
$(document).ready(function() { 
Enter fullscreen mode Exit fullscreen mode

And the solution was that I changed code on page initialization (code snippet above) to this:

<script type="text/javascript"> 
    beforeShow: function(){ 
Enter fullscreen mode Exit fullscreen mode

I applied callback on apex.messages before validation shows.
More about this can be actually found in apex JS DOCS

Also I found that on page login they used "old" approach, they render validation region, so setThemeHooks won't work here...

I did some thinking and came up with this scenario regarding apex js API:
You have apex 5 on development env. (because of faster development) and some old apex 4 production env. that for some reason it won't get upgrade in near feature. You use some specific apex JS API that is only available in apex 5 and you deployed that code to apex 4 production env. and then the fun starts :D

Big thanks to our poor organization, that we only support our clients directly on production... ;)

Discussion (0)

Editor guide