I’m building a login form composite component. The page that uses it will pass an event handler that will validate the username and password. Usually (not using composite components) when we perform cross field validation via postValidate, the event handler has to lookup the fields’ components by name. It would be preferable for the validator not to do this, because these are inner details of the component that should be abstracted.
Any idea how I might get the converted values of the username and password fields in a postValidate handler without knowing the inner details of the composite component?
Update:
The point of this is not to avoid looking up components by name at all, but to be able to cross-field validate the composite component’s fields in a way that doesn’t require the using page and/or bean to know the inner details of the component.
This can be done. In the following code, take particular note of the
postValidateevent in the composite component and thepostValidatemethod in the backing component. Notice how it resolves theMethodExpressionattribute and invokes the passed-in method.Here’s the composite component:
The backing component:
The
LoginFormValueclass for completeness:The page that uses the login form:
And finally, the page’s backing bean: