I implemented a way of doing validation in JSF using the strategy pattern, but this means that for each field in each HTML file I have to specify attributes to apply the right one.
Is there a way of doing it with less <f:attribute/>
or none at all?
My application implements the design Command pattern, and the validate method is inside a backingbean which is in session scope. The other beans, which I believe doesn’t help as info for the problem evaluation, are in session scope too (don’t ask, I know…).
<h:inputText
value="#{backingbean.form.value}"
id="someId"
binding="#{someBindingNameForValidationStylePurpose}"
validator="#{backingbeanInSession.validateForm}">
<f:attribute name="strategy" value="nameForTheSwitchInValidateFormMethod" />
<f:attribute name="validationStrategy" value="identifierForTheStrategy" />
<f:attribute name="field" value="specificValidationToApply" />
</h:inputText>
1