4 Replies Latest reply on Nov 16, 2010 1:09 PM by irace

    Validation of s:fileUpload

    jbuechel

      I'd like to validate data of the s:fileUpload component.


      Considering this topic i found this
      post on the old forum. Reading the post and the issue details I don't quite understand if it's currently possible to validate such a field (and how) or not.


      I'd expect something as the following:


      <s:fileUpload data="#{fwcInputProperty}" fileName="#{fwcInputFileName}" contentType="#{fwcInputContentType}">
           <f:validator validatorId="catalogTemplateValidator" />
           <s:validate />
      </s:fileUpload>


      Is something like this possible?


      Thanks for any information!

        • 1. Re: Validation of s:fileUpload
          gavin.king

          Try it.

          • 2. Re: Validation of s:fileUpload
            jbuechel

            :-) Of course i did try it before i wrote the post.
            After your reply I tried it again though, unfortunately without success. The (reduced) code:


            <s:validateAll>
            
            
                 <s:decorate template="#{theme.inputTextHorizontal}">
            
                      <ui:param name="fwcLabelMessageKey" value="catalogTemplate_label_name" />
            
                      <ui:param name="fwcInputProperty" value="#{catalogTemplateSelection.name}" />
            
                      <ui:param name="fwcInputRequired" value="true" />
            
                      <ui:define name="fwcInputValidator">
            
                           <f:validator validatorId="com.frox.aafn.action.validator.catalogTemplateValidator" />
            
                           <s:validate />
            
                      </ui:define>
            
                 </s:decorate>
            
                 
            
                 <s:fileUpload data="#{catalogTemplateSelection.file}" fileName="#{catalogTemplateSelection.fileName}">
            
                      <f:validator validatorId="catalogTemplateValidator" />
            
                      <s:validate />
            
                 </s:fileUpload>
            
            
            </s:validateAll>
            
            
            <h:commandButton value="#{messages['controls_save']}"
            
                 action="#{catalogTemplateAction.persistCatalogTemplate}" />
            
            


            The validate(FacesContext, UIComponent, Object) method is just not beeing called.


            I'd be happy if you could tell me what I'm doing wrong?

            • 3. Re: Validation of s:fileUpload
              shane.bryzak

              I think it's related to this issue:


              http://jira.jboss.org/jira/browse/JBSEAM-1981

              • 4. Re: Validation of s:fileUpload
                irace

                Are there any plans to make this work at some point ? As of now, it's impossible to use required or validator attributes
                for the s:fileUpload tag. Does anybody use this component in a real life application, and was able to find a satisfying
                workaround ?


                I'm ok with the team rejecting the proposed patch, but imho, the issue is far from closed, even on the 2.2.1.CR2 version,
                the one I use presently.


                Thanks
                Thom'