0
votes

I have a rich:tabpanel and several tabs. The tabpanel's type is set to 'client'. In each tab, there are some h:inputText.

What i wanna do is to show error like "Tab: Tab1[,Tab2[,Tab3...]] have error(s), please correct the error(s) before save." if there are errors among all tabs. I tried to implement this by AjaxListener(Seam) or PhaseListener(both can achieve what i wanna do).

The problem is that when there is some inputs that are marked with immediate="true", these inputs are validated firstly and separately from those inputs with immediate="false". Unless those "immediated" inputs contains no error, "non-immediated" inputs would not be validated.

Is there any way to force jsf validator to validate all inputs on some commandButton? or is there any way to override the default validator of jsf?

1

1 Answers

0
votes

There is no "default validator" in JSF, each component takes care of its own conversion and validation, if any. Components have callbacks that are invoked in each of the phases of the JSF lifecycle, and these callbacks invoke validation and conversion logic for each of the components in the component tree (so there is no centralized converter or validator).

Input components with immediate=false perform validation and conversion during the Process Validations phase (the third in the lifecycle), whereas input components with immediate=true do so in the Apply Request Values phase (the second in the lifecycle).

A "problem" (actually a design constraint) with the JSF lifecycle is that, whenever errors are found in any of the phases, the framework jumps directly to the Render Response phase without performing the remaining phases, so if any errors are found in immediate=true inputs (the second phase) the third phase is never invoked.

There is no workaround for this, you need to make all inputs immediate=false or immediate=true so that all validations take place in the same phase. I advice sticking to immediate=false unless you have good reason to do otherwise. If for example you need to have an action execute regardless of the validation status of inputs, make the commandButton immediate=true.