|
|
You have an XPage with a tabbed panel and a submit button. Each tab contains required fields however validation only occurs on the tab that currently has focus. Hence, if you submit the page, validation does not occur on the tabs which do not have focus. This behavior is working as designed and an enhancement request (SPR # PHAN82BLDU) has been created to add functionality that will validate all tabs when submitting. So how can we validate all the tabs?
Well, validation does occur on the current tab so all we need to do is force the end user to visit each tab. One way to do this is to move your submit button to a "Submit tab" and disable it until the end user has visited each tab. You can track if a tab has been opened by using a sessionScope variable for each tab. For example, I have 3 tabs, each with a required field and a fourth tab with my submit button:
In the beforePageLoad event of the XPage, I set my two sessionScope variables to determine if the second and third tab have been opened.
sessionScope.TabTwo=false;
sessionScope.TabThree=false;
Since I have set my XPage to open to the first tab, I don't need to keep track of the first tab.
To prevent the user from submitting the page until all tabs have been visited, I enter the following Disabled formula for my submit button:
!(sessionScope.TabTwo && sessionScope.TabThree)
To mark a tab as visited, I use the onclick event of the tab to execute the follow script:
sessionScope.TabXXX=true;
Finally, to make the XPage user friendly, I add a computed field with the follow JavaScript next to the submit button to indicate why it is disabled.
if (sessionScope.TabTwo && !sessionScope.TabThree)
"Field Required on Tab Three"
else if (!sessionScope.TabTwo && sessionScope.TabThree)
"Field Required on Tab Two"
else if (!sessionScope.TabTwo && !sessionScope.TabThree)
"Fields Required on Tab Two and Three"
else
""
Example database provided in attachment section. |
|
|