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:
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:
43 comments:
Is there any way to skip required fields validation when switching between tabs and perform it only on submit?
Its what this post about. Isnt it?
Andrejus
I meant: switch to the second tab without entering required values in the firs tab :).
This is what I describe in this post: "Because of Immediate = true - we can open second tab without getting validation errors"
Andrejus
Hi Andrejus,
Don't know what I'm doing wrong but I still get the not null validation messages. I've:
1) Downloaded the zip sample
2) Changed "SkipValidation" to both emplsViewPageDef and mainPageDef
3) Both Contact and Details showDetailItem have Immediate property to false.
Thanks a lot in advance.
Jose.
There is no need to change anything - skipValidation = true is already set on Employees fragment.
This sample was implemented with ADF 11g R2, which ADF version are you using?
Andrejus
Hi Andrejus,
I'm trying to use this solution with a series of Show Detail Headers (these are populated by an iterator). When I add a row and try to disclose the (empty) contents, I'm getting validation errors; even after following the steps described. Should this solution work for these Show Detail Header elements as well?
Using 11g R2.
Thanks,
Alex
It should work, I would need to test it.
Andrejus
Thank you for this.. really helpful :)
-adfBeginner
I have added SkipValidation="true" to my pageDef page and also I added immediate="true" and also immediate="false" to af:showDetailItem,but both are not working.For both case,I can't go to select tabs.
Can you please give idea?
Does it work when you test with my sample app?
Andrejus
Hello Andrejus
I have a quite similar problem, but not exactly the same.
I ve 2 tabs on each one there are required filed. The submit button is outsite the af:paneltabbed.
Suppose I am on the first tab, I ve not inserted anything yet on the second one, I submit -> the required fileds of the second tab are escaped, no error message is displayed.
How can I make the submit button controls the required fields of both tabs.
I ve tried to put both tabs to immediate=true, I also tried childCreation=immediate on the panelTabbed: don't work
Thanks a lot for help
Did you try to use skipValidation=true as this post describes?
Andrejus
Hi Andrejus,
I have two tabs, one is having mandatory fields and the other showdetails tab is not having any mandatory fields.
Now the problem is when I try to submit the form from the second tab without giving the mandatory attribute on the first tab, it gets submitted.
I want to prevent this form submission by prompting some error message or something.
any help will be highly appreciated.
Hi Andrejus.
Why we need skipValidations here, we dont' have any entitylevel validation.
i have run this project with skip validations = false.not finding any difference. Can you please tell what impact it has.
Thanks.
You should read blog more carefully. There are EO level validations - required attribute check. With skipValidation = false, it will report errors from other Tab, on Commit. Double check what I describe in the blog post.
Andrejus
hey Andrejus,
so what would be the preferred way of dealing with view level validation? Say, if I would set the "required = true" on one of the attributes and try to change tabs without giving it any value?
I have a case with rather complex form spread on multiple (nested) tabs and some of the fields become required depending on phase of some process.
Thanks,
lukasz
This is described in this post, set immediate=true for the tab and skipValidation=true in Page Def. Unless your case is different.
Regards,
Andrejus
Maybe I'm missing something then.. From how I understand your post "Immediate = true" will not solve described issue plus entered data is not stored on the Model.
I figured out, that setting the top-most tab containing the required fields as immediate actually helps (errors on empty fields are not show on tab change but the values go to the model on save just fine) yet I'm not quite sure why..
According to the doc setting "immediate = true" on components that invoke disclosure events will only pull conversion, validation and event delivery up to the 'Apply Request Values' phase so required fields with no value should throw an error..
So my satisfaction from getting this to work is not full ;)
Still, thanks for the post(s),
lukasz
Yes, this is why you need to set additionally skipValidation=true, as I describe in the post.
Andrejus
:) you got me confused, Andrejus.. In your post you are setting immediate back to false before setting "skipValidation = true". I, on the other hand, have "immediate = true" and "skipValidation = false" (I don't have any Model validation that needs skipping). Everything is working (almost) as should, I'm just trying to figure out why.
This post described to leave immediate as default and set skipValidation=true. I don't know about your use case, but in this case it works - I can navigate across tabs, without firing validation messages on tab disclosing.
To set immediate=true doesnt work well, as it will not submit values from the current tab, while moving to the next tab.
I hope it is more clear. I'm not sure about your code and use case, may be there is something else. It would require debugging :)
Andrejus
Hi Andrejus,
setting skipValidation = true on pageDef is still invoking validations on selectOneChoice fields. Am I missing something ?
I think this should work fine, at least it works in our projects. But, I can double check.
Andrejus
yes please, I tried setting skipValidation = true, also immediate = true. still the validation are getting triggered on value change instead of final form submit.
I am facing this issue in editable table when columns are LOVs (selectOneChoice).
Any pointer to resolve this issue would be appreciated..
Hi Andrejus, it would be really helpful if you can solve my problem, I have dynamic LOV's being created with dependent LOV's at EO level, both the LOV's are mandatory, so the problem happening is when i input a value in one LOV "tabbing" which a value change listener is called with phaseId : "ANY Phase" where we change the phaseId to "Update..." , so before the value change listener is called again by jsf, the mandatory parameter validation of 2nd dependent LOV gets called and value change listener call gets skipped. SO we get an empty dependent LOV. Tried with setting SkipValidation=true, didnt helped
Hi Andrejus,
I have an form with Business Components (in with multiple fields such as inputFields, selectOneChoice and DatePicker. Some fields are marked "required=true", some are not. I have two use cases - validations work as I want those to on one, but not on the second case.
Use-Case 1: At the start, I click create and empty rows are created in the form. Then I click on a commandButton when the fields are empty and an error message pops up. This is expected behaviour.
Use-Case 2: I enter a value in the textInput, then without clicking commandButton, remove the above entered value from the inputText and make it empty again. On change of focus from this field to another, ADF pops an error saying this is a required field.
I want ADF to give this required field error on click of Submit and not on change of focus from field.
"immediate=false" for all my input components, "required=true" for mandatory fields. I also have method reference to a validator method for these fields. "skipValidation" in the PageDef is set to false.
I tried setting "skipValidation=true", but Case 2 is still not working as I want it to.
Do you have any idea how can I make this work? Your guidance should certainly help.
Thanks,
Rohan
Andrejus thanks a lot for this post.
I don't understand when we should use skipValidation. OK, in this case it works fine, but what is the rule to use it? what happens in respect to jsf lifecycle? I don't really understand what skipValidation does.
debugging a page like that would be really difficult to find out it uses skipValidation...
thanks a lot
AK
I have two tabs, one is having mandatory fields and the other showdetails tab is not having any mandatory fields.
Now the problem is when I try to submit the form from the second tab without giving the mandatory attribute on the first tab, it gets submitted.
I want to prevent this form submission by prompting some error message or something.
Can someone point on a solution to this issue?
I think this should work by default, when your fields are based on the same EO/VO.
Andrejus
Hi Andrejus, thanks a lot for useful posts.
I've recently had a post about attribute validation on Input List Of Values on OTN, that the validation error message isn't displayed with InputListOfValues :
https://community.oracle.com/thread/3701074?sr=inbox&ru=784421
also in this blog has benn pointed out :
http://adfbugs.blogspot.nl/2009/11/attribute-validation-on-input-list-of.html
do you have any suggestion for solving this problem?
What you are trying to achieve is not supported. LOV list must contain only valid values.
Regards,
Andrejus
Hi Andrejus,
I've just seen your post about Workaround for Infamous Bug 13626875 :
http://andrejusb.blogspot.nl/2013/12/workaround-for-infamous-bug-13626875.html
, that you said if we apply ExceptionMode = Immediate setting for Data Control Usage in DataBindings.cpx, then the error message is displayed.
Regards
Habib
Cool :)
Hi Andrejus,
I just need to inform you that I downloaded your app and run it under JDeveloper 12.1.3, and 12.2.1 . Immediate is false as it should be, and skipValidation is set to true (you already preconfigured this all). But there is problem. In both versions I can't switch tabs. I will not asq why. I would like to asq however if there is something different in JDeveloper 12.1.3 and 12.2.1 considering skip validation? I simple can't find any explanation why your app is not working under this versions. Regards and thanks for great article.
Thank you so much! You have no Idea how much this blog (and many more of your blogs) helped me out.
This makes me happy, thanks.
I Have a scenario where I use dynamic tabs in which i have a landing page consists of some student details. When i click on a student to get full details, it is opening fine and data is rendering properly in a new tab. Without closing that tab navigating back to landing page and clicking on another student is also opening fine in a new tab. But when i navigate back to the previously opened student details tab the page is blank now. can you help me what could be the problem
Hello,
Thanks for the post.
When i set skipValidation=true and i have a popup for my crud operation on my ADF 12c webapp, the validation msgs( shown programmatically) on IE 11 disappears for the first time.
Any inputs on that?
If i set skipValidation=false, then this disappearing of msg does not happen but we have the problem of required fields which your blog addresses.
This thread posts the same question.
https://community.oracle.com/thread/3644936
Hello Andrejus
I have a quite similar problem, but not exactly the same.
I ve 2 tabs on each one there are required filed. The submit button is outsite the af:paneltabbed.
Suppose I am on the first tab, I ve not inserted anything yet on the second one, I submit -> the required fileds of the second tab are escaped, no error message is displayed.
How can I make the submit button controls the required fields of both tabs.
I ve tried to put both tabs to immediate=true, I also tried childCreation=immediate on the panelTabbed: don't work
Also i have skipValidation=true,Still not resolve my problem
My use case is-
I have Create jsff in CreateTF for E1, from the Create jsff i drilldown to Create jsff of another entity E2, after entring the required data on Saving the jsff it throws a validation error of required attribute from E1.
I tried having skipValidation="true" in pageDef for both the entities, still i am getting the issue
Hi Andrejus
I have studied your blog.I have a small requirement.I wnt to restrict user not to enter into another field untill he puts the value in first field.i wnt to show the user that this field is mandatory..
Thanks Andrejus Baranovskis .
This helped me a lot and got a task done where the requirement is exactly the same as the post.
Post a Comment