7 Replies Latest reply on Mar 17, 2009 11:51 PM by kragoth

    s:fileUpload quick question

    kragoth

      Hey guys.


      We are working on a page where the user is to upload some CSV files. Currently we are using the s:fileUpload tag and it is doing almost everything we want. And if we were writing our app for Firefox then it would be doing absolutely everything we want!


      The problem we are having is that I want to stop people from typing in the name of the file. I only want users to be able to select a file by using the browse button. Is there any possible way of doing this? I've tried everything I can think of.


      These are some of the things I've tried.


      -return false on the onkeypress event - this doesn't work, the event fires but ignores the return false and the key stroke still appears.


      -set readonly = true - this doesn't work either. (even setting it via javascript doesn't work)




      The reason I ask for this is that I have an onsubmit event that displays a Please Wait message. This event works perfectly fine on all our pages except the one with the fileupload component on it. The problem occurs if I just type random stuff into the input box and click my submit button. The onsubmit event fires but no post happens. So my please wait dialog pops up and never dissapears.


      Any help/ideas would be greatly appreciated.


      Thanks,
      Tim Evers

        • 1. Re: s:fileUpload quick question

          This is really not Seam-related. Seam just renders the ordinary input tag with type set to file. Check javascript forums... :-)

          • 2. Re: s:fileUpload quick question

            I bet you could use jQuery to your advantage.


            With jQuery you could just make the input field of the this control go poof! - just give the control an id that you can use in the onReady event of jQuery. View source to see if id is applied to text box or browse button.
            Another idea would be to enclose the control in a span, use the span's id, use jQuery find syntax to look for any input text fields within this span and hide them.


            Sorry if I am vague here, don't have any code to play with but I would definitely look at a jQuery solution.


            • 3. Re: s:fileUpload quick question

              On second thought perhaps on hiding the input field the upload control will not work as expected ?, you could set it to disabled or read-only instead with jQuery


              Another option is to that a keypress in the input field should trigger the Browse button click, kinda like how rich:calendar works.


              Rich Calendar




              • 4. Re: s:fileUpload quick question
                kragoth

                Hi Franco,


                Thanks for your ideas! I havn't tried jQuery yet and I'm not sure I want to introduce another technology into my project at the moment.


                I would be happy enough with keypress clicking the browse button. But I'm not sure how to do that as the browse button does not have any id.


                I would even be happy with just ignoring all keypress events, but it seams that the way that SEAM renders this component out it is impossible to do that.


                Daniel Roth,


                This isn't really a javascript question because without SEAM I can get the desired behaviour. If I just write plain html I can get the component to work in a way that would satisfy my requirements. However using the s:fileUpload component does not let me do this.


                <input id="testInput" type="file" onkeypress="return false;"></input>
                


                The above line of code works fine in plain Html. This will stop all keyboard entry. However, if i use the onkeypress=return false in the SEAM component it doesn't stop the key inputs from working.


                So I think that this is a SEAM related question.

                • 5. Re: s:fileUpload quick question
                  kragoth

                  Should I raise this as a JIRA or am I missing something about this component?

                  • 6. Re: s:fileUpload quick question
                    pregnirit

                    Have you tried the syntax JavaScript:return false; ?

                    • 7. Re: s:fileUpload quick question
                      kragoth

                      I just gave that a go and I'm experiencing the same behaviour.


                      I can still enter text into the field.