-
1. Re: Bean Validation
jpleed3 Jan 12, 2010 3:52 PM (in response to jpleed3)If I add Ctrl-V... Ctrl-V... Right-click... WTF, the new forum doesn't paste?
Anyway, if I add <f:validator validatorId="javax.faces.Bean" /> to an input field, then bean validation will validate that field as expected. According to the JSF 2 spec section 2.5.7, JSF is supposed to pretty much do that for every UIInput.
So I figured maybe I could add this:
<application>
<default-validators>
<validator-id>javax.faces.Bean</validator-id>
</default-validators>
</application>
No luck there.
-
2. Re: Bean Validation
ilya_shaikovsky Jan 19, 2010 5:36 AM (in response to jpleed3)import javax.validation.constraints.Size; /** * Created by JBoss Tools */ public class Person { @Size(min = 2, max = 3) private String name; public Person() { } public String getName() { return name; } public void setName(String name) { this.name = name; } }
and
<h:form> <h:inputText value="#{person.name}"> <rich:beanValidator /> </h:inputText> <h:commandButton value="Submit"/> <a4j:commandButton value="Ajax Submit"/> <rich:messages/> </h:form>
both buttons causes messages to appear for me. I've used for test next env:
- hibernate-validator-4.0.2.GA,
- RichFaces 3.3.3 - snapshot
- JSF 2.0.1
- tomcat 6
-
3. Re: Bean Validation
jpleed3 Jan 19, 2010 9:52 AM (in response to ilya_shaikovsky)I'm running on Glassfish v3, so everything I need should be in the classpath, aside from Facelets 1.1.15 and RF 3.3.3.
As long as a JSR-303 implementation is available, JSF 2 should automatically add the validator to every UIInput, unless the context-param javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR is set to true. See JSF 2.0 spcc, section 2.5.7.
So - at least from my understanding - it shouldn't be necessary to add <rich:beanValidator /> in JSF 2. I mean, I can understand why we can't use JSF 2 tags like f:ajax with RichFaces 3.3.3 - they simply don't exist in Facelets 1.1.15. But this shouldn't have anything to with the PDL, should it?
-
4. Re: Bean Validation
ilya_shaikovsky Jan 19, 2010 10:38 AM (in response to jpleed3)thanks for this update. I will continue investigation. -
5. Re: Bean Validation
ilya_shaikovsky Jan 22, 2010 8:35 AM (in response to ilya_shaikovsky)Can't find precise place in JSF 2 specification but it seems for me that validators not instantiated by default if running in jsf 1.2 compatibility mode. I tried to create simple JSF 2 project from scratch and validators worked as you told till I added Facelets 1.1.15 and turned default VDL viewHandler off. Then I tried different definitions but default validators no more working without to be explicitly defined.
Thanks! I will add this to compatilibity limitations wiki document.
-
6. Re: Bean Validation
jpleed3 Jan 22, 2010 9:39 AM (in response to ilya_shaikovsky)I don't think javax.faces.VALIDATE_EMPTY_FIELDS works either. I've gotten BV to work without the rich:beanValidator tag by using a phase listener that adds BeanValidator to all UIInputs, but I still have to put required=true on the inputs. -
7. Re: Bean Validation
jpleed3 Jan 22, 2010 4:11 PM (in response to ilya_shaikovsky)I filed an issue with Mojarra; maybe this limitation will get some attention: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1518