-
1. Re: Hibernate Validator on non-entity seam backing beans
joblini Oct 21, 2008 4:48 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Try nesting <s:validate/> within each <h:inputText> instead of <s:validateAll> in layout/edit.xhtml.
-
2. Re: Hibernate Validator on non-entity seam backing beans
bogdanminciu.bogdan.minciu.yahoo.com Oct 21, 2008 9:34 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Thank you Ingo for your reply. This method doesn't work either. The field constraints are simply ignored.
For me, it seems that the Hibernate Validator only works with entities that are persisted into the database. I marked this bean with @Entity, but if I don't persist it with entityManager, the constraints are ignored.
But I have read that the validator could be used on non-entity beans. Is there a configuration file I should know about? Thanks.
-
3. Re: Hibernate Validator on non-entity seam backing beans
deanhiller2000 Nov 6, 2008 9:13 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)Do you have the pages.xml correct?
<action if="#{validation.failed}" execute="#{globalMethods.invalid()}"/> public void invalid() { facesMessages.add("Errors below in form. Please correct and resubmit"); }
I do and am having the same problem. My globalMethods.invalid is NOT being called which would set the global messages to be displayed like the booking example. It gets to the apply request values phase and then for some reason skips all the other until render response. It does not hit the validation phase which I find weird, but still, shouldn't my action above be called.
You might just be missing the action above...check out the register page of booking example.
-
4. Re: Hibernate Validator on non-entity seam backing beans
yanmania Nov 23, 2009 10:22 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)I have the same probleme. I am using JBoss Seam 2.1.1.GA. Is there a solution or a workaround to this problem.
-
5. Re: Hibernate Validator on non-entity seam backing beans
deanhiller2000 Nov 23, 2009 3:49 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)shouldn't the validator annotations be on the get methods not the fields? I have never used them on fields before so I don't know if that works. I typically put JPA annotations on fields and hibernate validator annotations on get methods.
ie. it passes validation because no annotations on the get methods mean nothing to validate maybe? hmmm, not sure why I didn't see that last time I was on this thread.
Dean -
6. Re: Hibernate Validator on non-entity seam backing beans
yanmania Nov 23, 2009 5:04 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)It sounded like a good idea because JSF uses get methods and not directly field properties. But it does not work either.
-
7. Re: Hibernate Validator on non-entity seam backing beans
deanhiller2000 Nov 23, 2009 9:28 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)well, drop in the phaseTracker.jar into WEB-INF/lib so at least it is logging what JSF phases it is going through and then you can tell if it dropped out at the validation phase or went through to a later phase. Also, I can't see any kind of template for the decorate element and there could be a problem with that. you should really post your code though, java bean, and xhtml and decorate template used.
-
8. Re: Hibernate Validator on non-entity seam backing beans
asookazian Dec 1, 2009 11:55 PM (in response to bogdanminciu.bogdan.minciu.yahoo.com)
Bogdan Minciu wrote on Oct 20, 2008 22:52:
Is it possible to use Hibernate Validator on simple, non-entity Seam backing beans like the one above? What am I missing? Any help would be highly appreciated.IIRC, no. I think PMuir answered this question for me by saying that you should use Seam custom validator instead of Hibnerate validator for this case (backing bean).
I'm not sure it's ok to use Hibernate validators with Seam backing beans (non-entity classes). But I can't find that post/thread on google...
-
9. Re: Hibernate Validator on non-entity seam backing beans
asookazian Dec 2, 2009 12:00 AM (in response to bogdanminciu.bogdan.minciu.yahoo.com)
I have tried using Hibernate Validators (e.g. @org.hibernate.validator.Pattern) with SFSB/SLSB methods. This is not recommended or supported in the context of a Seam application.http://seamframework.org/Documentation/BusinessValidationWithJSFAndSeam
Unfortunately, I did not explain why it's not recommended or supported... Any takers?