Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3299

Programmatically generated components do not register with Bean Validation



    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None


      I am having problems using MyFaces with Bean Validation.

      I am not clear what the JSF spec means, but it says "Consider a simple web application that has one page, written in Facelets for JSF 2, that has a several text fields inside of a form. This application is running in a JSF runtime in an environment that does require JSR 303 Bean Validation, and therefore this feature is available. Assume that every text field is bound to a managed bean property that has at least one Bean Validation constraint annotation attached to it. During the render response phase that always precedes a postback, due to the specification requirements in Section 3.5.3 "Validation Registration", every UIInput in this application has an instance of Validator with id javax.faces.Bean attached to it".

      George Gastaldi and I have created a sample application (attached) that demonstrates several ways of creating a simple input text bound to Bean Validation. This must be deployed to a Java EE 6 container (we tested against JBoss AS 6). You will note the first two pages (Normal Facelets form, Binding Component) work fine. When you click 'Click Me' to POSTback, Bean Validation is invoked and a validation error is displayed.

      The second two pages (Dynamic Component, Dynamic Component (with Metawidget)) do not work as expected. They both use PreRenderViewEvent to create the inputText programmatically. The spec is unclear whether we're meant to explicitly add a javax.faces.Bean validator in this case? The way I read section 3.5.3, I don't think we do, but it doesn't work without it?


        1. jsf-validation.zip
          10 kB
          Kennard Consulting



            lu4242 Leonardo Uribe
            kennardconsulting Kennard Consulting
            1 Vote for this issue
            3 Start watching this issue