Quantcast
Channel: Andrej Baranovskij Blog
Viewing all articles
Browse latest Browse all 706

Skip Validation for ADF Required Tabs

$
0
0
Tell me - how often it happend to implement such basic layout where required attributes from one Entity are located on the same fragment/page but in different tabs? I guess quite often, this is common requirement. However, is not so obvious how to implement it properly. Most likely you will end up into infinite loop of validation errors for required fields when trying to switch between tabs. I will describe in this post how to implement multiple tabs with required attributes from the same Entity and avoid unexpected validation errors.

Sample application - TestValidationApp.zip is based on Employees EO and contains two tabs - Contact and Details. Half of Employees attributes are located under Contact and the rest under Details tab:


Firstly I will show you how it works by default. Press Create button, this will call CreateInsert operation and insert new row (attributes from this row will be initialized blank in both tabs):


Type values for required fields and try to open second tab - Details. Validation errors are displayed for missing attribute values in the second tab. But wait a bit - we want to open Details tab and already getting validation errors? This makes our form unusable:


Let's make first attempt to solve this problem - set Immediate = true for both tabs. In theory this should help, in practice it doesn't. Immediate = true allows to skip validation lifecycle, but as a side effect it prevents Model update and value is not set.  Immediate = true will not solve described issue, but still let's test it - I will show you why Immediate = true doesn't help at all. Select both tabs in JDeveloper:


Set Immediate = true property for both tabs:


Do the same test again - create new record and type required values in the first tab:


Because of Immediate = true - we can open second tab without getting validation errors. Type required values in the second tab and press Save. Validation errors are reported for the required values in the first tab. This is quite a magic, actually not - this happens because of Immediate = true - entered data is not stored on the Model:


Set Immediate = true to be false for both tabs, as it was originally:


Solution will be described now. Open page definition file and select root tag in the structure window:


Go to Properties window and search for SkipValidation property. Set SkipValidation to true:


This allows to prevent such silly validation execution as you saw above. Enter required values in the first tab:


Switch to the second tab - enter required values there. Press Save button to commit transaction - no errors this time:


SkipValidation = true doesn't affect regular ADF validation behavior - if required field value is missing during transaction commit - ADF will stop processing and ask user to provide a values as expected:


Viewing all articles
Browse latest Browse all 706

Trending Articles