8 Replies Latest reply on Mar 4, 2010 10:13 AM by Ricardo Araujo

    FileUpload - Disable UPLOAD (start) Button only

    Ricardo Araujo Newbie

      Hi...

       

      is not possible to disable (or hide) only the upload/start button??  Why???

       

      I did a workaroud taking the button ID (dom/tag) and hidding it. However, after calling the OnClear event, the own component (fileUpload) show it again (having at least one file).

       

      Anybody suggest another way (to get control of upload button)??

       

      Thks a lot.

       

      Carvo.

        • 1. Re: FileUpload - Disable UPLOAD (start) Button only
          Nick Belaevski Master

          Hi,

           

          You should be able to achieve this using CSS classes.

          • 2. Re: FileUpload - Disable UPLOAD (start) Button only
            Ricardo Araujo Newbie

            Hi Nick,

             

            thx for reply.

            The doc is not clear enough, but how I do it? Do you have some sample code? Through this way, the OnClick event will be disabled?

             

            Coz in the doc, there are one away to disable and is using $(..).component.disable(), but it disable all buttons.

             

             

            Thx again.

            Carvo.

             

            ps. sorry my poor english.

            • 3. Re: FileUpload - Disable UPLOAD (start) Button only
              Nick Belaevski Master

              Every RichFaces component comes with a number of predefined rich-* classes (see component chapter in user guide for the list). So you can these classes to hide the button forever, not disable.

              1 of 1 people found this helpful
              • 4. Re: FileUpload - Disable UPLOAD (start) Button only
                Ricardo Araujo Newbie

                Hi Nick,

                thank you for your patience.

                 

                I read this chapter but did not find how to do this by predefined classes.

                But as I said above, I did it using the ID of the button, but the event OnCancel overwrites my action. It's really depressing to use a component so complex that has not a simple beforeAdd (), beforeUpload (), beforeCancel () and etc (and their respective after methods), or even the independent control of its features (getStartButton or better, disable/enable startButton functions).

                 

                 

                Thx again.

                Carvo.

                 

                ps. I am saying this because I have another problem in the event OnAdd. At one point im trying to clear the list with $(..).component.clear(), but this is also overwritten later,and the list remains the same (the same before the OnAdd event fires).

                • 5. Re: FileUpload - Disable UPLOAD (start) Button only
                  Ilya Shaikovsky Master

                  define maxFilesQuantity attribute with EL which will be evaluated as 0 while conditions for upload not met. And then change when upload available via ajax rerendering the FU.

                   

                  Unfortunatelly we added the same css classes for both buttons (a shame ) so just client side solution will not looks good as it will hide both buttons.

                  1 of 1 people found this helpful
                  • 6. Re: FileUpload - Disable UPLOAD (start) Button only
                    Ricardo Araujo Newbie

                    Hi Ilya,

                     

                    many thx for your reply.

                     

                    I'm implementing a lot of validation (client and server) to prevent users from making sh.....

                     

                    But I intend to use this time to gracefully ask that implements some "predefined class wrapper" methods like disableStartButton() and so on...

                     

                     

                    Thx for all help..

                    Carvo.

                    carvo33@hotmail.com

                    • 7. Re: FileUpload - Disable UPLOAD (start) Button only
                      Ilya Shaikovsky Master

                      created simple workaround:

                       

                      <script>
                      function switchUploadControl(id, expanded) {
                            var button = $(id + ":upload2");
                            if(expanded) {
                                 Element.hide(button.parentNode);
                            } else {
                                 Element.show(button.parentNode);
                            }
                      }
                      </script>
                      <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
                           maxFilesQuantity="#{fileUploadBean.uploadsAvailable}" id="upload"
                           uploadControlLabel="&lt;i&gt;Upload1&lt;/i&gt;"
                           immediateUpload="#{fileUploadBean.autoUpload}"
                           acceptedTypes="jpg, gif, png, bmp"
                           allowFlash="#{fileUploadBean.useFlash}">
                           <a4j:support event="onuploadcomplete" reRender="info" />
                      </rich:fileUpload>
                      <button type="button"
                           onclick="switchUploadControl('#{rich:clientId('upload')}',false);">enable</button>
                      <button type="button"
                           onclick="switchUploadControl('#{rich:clientId('upload')}',true);">disable</button>
                      
                      • 8. Re: FileUpload - Disable UPLOAD (start) Button only
                        Ricardo Araujo Newbie

                        I created something like that, but my problem comes after the OnClear event. If my validation fails (after OnClear), i need to hide the button, but the component show it again (like i said in first thread). So, i need to ask you "one" more thing: to create a before and after event methods (for those that not have, obviously).

                         

                        Really thanks for your time.

                         

                        CARVO.