I’m using JSF 2 and Primefaces. But I now need to do some more complex validation, specifically cross-field validation and perhaps some validation involving expression language (so I can do conditional validation in my xhtml pages).
I don’t think I can do these with my current setup, but I’ve been reading about various other addons that I could be using such as:
- Seam
- ExtVal
- JSR303
Was just wondering what the most recommended approach was. Does ExtVal need MyFaces as a pre-requisite? And if so, will MyFaces conflict with PrimeFaces?
I’ve experimented a bit with different jars and run into what look like a few conflicts so appreciate any feedback.
[Update]
As per my comment I went with OmniFaces which was just a case of downloading the jar file and then adding the namespaces to my page:
...
xmlns:o="http://omnifaces.org/ui"
xmlns:of="http://omnifaces.org/functions"
...
And then I used this as a test case (to make sure password and confirmPassword are both the same, but only when one of them has a value). This solves both my ‘issues’ very easily.
<o:validateEqual id="equal" components="password confirmPassword" disabled="#{editUserAdminController.user.password != '' || editUserAdminController.user.confirmPassword}"/>
Thanks
EDIT: JSF can use an implementation of
JSR303in case one is provided by the application/server. Cross-field validation is a bit tricky but definitely can be done with the tech availabe.You may also want to take a look at the OmniFaces library – it features cross-field validation among many other useful things and is not tied to a particular JSF framework.