APEX has an extensive set of built-in validations to capture every eventuality. They pop up an informative notification message and can direct the user directly to the fault.
Validations, however, only activate when a page is submitted. This is great in almost every case… well… what if you don’t want to submit your page?
For example, your page makes use of dynamic actions to process data (and there are reasons why you’d choose to do this which we won’t go into here). So how do you alert the user when the input data does not validate?
Consider an example:
Within a region, there is a single text item (P1_TEXT_ITEM) and a button (P1_BUTTON). We want a dynamic action on the button so that when the user clicks the button, it inserts the value of the text item to a table. We also need to alert the user when there text item is null. You may have other validations within your application; so you want the user to see consistent looking validation messages.
This blog demonstrates consistency by combining APEX Validations with Dynamic Actions
To Demonstrate this:
(Note: If your code is over 4000 characters, there is a workaround on our blog)
Page Items to Submit: p1_text_item
Page Items to Return: p1_validation_failed
Fire on page Load = Un-ticked
So what the above is doing is hiding the Error notification message and removing the Label error if you have an error message display location set to “Inline with Field”. These errors will either stay hidden if the page passes validation or reappear is the page fails validation. It then submits the page, firing the validation, if the PL/SQL process failed validation.
Author: Matt Mulvaney
Job Title: Senior Oracle APEX Development Consultant
Bio: Matt is an experienced APEX solution designer having designed numerous complex systems using a broad range of Oracle Technologies. Building on his previous experience of Oracle Forms & PL/SQL, he is entirely focused on providing functionally rich APEX solutions. Matt promotes APEX as a software platform and openly shares best practises, techniques & approaches. Matt has a passion for excellence and enjoys producing high quality software solutions which provide a real business benefit.