6 Replies Latest reply on Jul 26, 2006 1:24 PM by gavin.king

    Can <s:validate> be used with facelets compositions?

    phicorp

      Hello All,

      If I create a custom facelets tag such as the following tag

      <p:myTag fieldValue="#{user.name}"/>

      which uses the following custom facelets composition

      <ui:composition>
      <h:inputText value="#{fieldValue}"/>
      </ui:composition>

      then using <s:validate> with the custom tag will result in a runtime exception thrown by <s:validate>.

      Does anyone know whether or not this issue is being addressed, as I would like to use <s:validate> if the issue is resolved?

      Many thanks,
      Bruce.

        • 1. Re: Can <s:validate> be used with facelets compositions?
          pmuir

          I've raised this before and there didn't seem to be much interest in fixing it. I modified the ModelValidator class to take a property attribute. If the property attribute is supplied it is used instead of the value attribute. I also use the 'property' as the key for localised labels for fields and as an id for attaching messages.

          E.g.

          <p:myTag fieldValue="#{user.name}" property="user.name"/>
          


          <ui:composition>
          <h:inputText value="#{fieldValue}">
           <p:validate property="#{property}" />
          </h:inputText>
          </ui:composition>
          


          See http://jroller.com/page/pmuir?entry=modelvalidator

          • 2. Re: Can <s:validate> be used with facelets compositions?
            phicorp

            Getting a permanent long-term solution into the Seam codebase is a great solution, but for me patches outside the Seam codebase are not a solution.
            Are we sure that there is no way around the problem without changing Seam?

            • 3. Re: Can <s:validate> be used with facelets compositions?
              pmuir

              AFACIS no. The ModelValidator in Seam uses ValueBinding.getExpressionString() to work out the seamComponent.property (i.e. getName() on the seam component user) and hence get the validator to use. When using a facelets source tag the ExpressionString is not a seamComponent.property but 'fieldValue' (which has no validator attached). There is no way (AFAIK) of working up the chain of EL expressions to get the root one.

              (Btw. My solution isn't really a patch, just a replacement component, so rather than doing s:validate you do model:validate. There is no patching of Seam source required, just adding another jar to the library directory.)

              • 4. Re: Can <s:validate> be used with facelets compositions?
                phicorp

                Thanks for your reply and I will think about what you said.

                Nevertheless I wish that the main Seam players recognised the importance of the issue we are discussing, as I don't think that anyone using facelets would give up its composition facilities in order to use <s:validate>.

                • 5. Re: Can <s:validate> be used with facelets compositions?
                  pmuir

                  There was some discussion on the facelets list a couple of days ago about this. A couple of possibilities were mentioned, and Jacob Hookom said that he hoped that future versions of EL would allow this to work. When I have a moment I will see if I can get either of the possibilities to work.

                  • 6. Re: Can <s:validate> be used with facelets compositions?
                    gavin.king

                     

                    Nevertheless I wish that the main Seam players recognised the importance of the issue we are discussing, as I don't think that anyone using facelets would give up its composition facilities in order to use <s:validate>.


                    AFAICT, this is not a limitation of Seam but a limitation of Facelets, and so there is nothing much I can do about it.