tabbed panel validation in Struts2
-
07-07-2021 - |
سؤال
I have a tabbed panel with 4 tabs. On the 3rd tab I have 3 textfield and submit button. How to do validation for this tab .On validation error how to return to same tab(i.e. 3 rd tab). When i tried with XML validation it returned to first tab not 3rd tab when validation failed (resutl type="input").
المحلول
TabbedPanel uses (or not, the choice is on you) a cookie to remember the last visited Tab.
You can't use it dynamically if i remember well:
you can ALWAYS remember last visited Tab, OR you will ALWAYS start from the first Tab.
If you want to remember the current tab, insert the
useSelectedTabCookie="true"
attribute into the
<s:tabbedPanel>
tag, with the result that if you are trying to submit data on TAB 3 and validation will raise an error, you will return on the page in the Tab 3.
I suggest you to not submit multiple tabs with one button, every tab should have its own.