Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Uploading files to server using SmartClient JS 8

    Hi,

    Using SmartClient 8, I'm trying to upload a file to the server. I don't have the Smartclient server stuff
    installed, but rather use a custom servlet on my server to handle this.

    Here's an extract of the code I have:

    Code:
    this.uploadForm = DynamicForm.create
    ({
    	saveOnEnter : false,
    	canSubmit : true,
    	encoding : DynamicForm.MULTIPART_ENCODING,
    	action : 'servlet/upload',
    	target : 'myUploadFrame',
    	fields :
    	[
    		{ name : 'file', showTitle : false, type : 'binary', width : 250 }
    	]
    });
    
    this.uploadFrame = HTMLFlow.create
    ({
    	ID : 'myUploadFrame', contentsURL : '', contentsType : 'page', width : 100, height : 100,
    	border : '2px solid black',
    	getIFrameHTML : function (url)
    	{
    	// require overriding this method, because the id attribute doesn't get output in ISC's implementation
    	    return '<iframe height="100%" width="100%" scrolling="no" id="' + this.ID + '" frameborder="0"></iframe>';
    	}
    });
    
    ...
    ...
    this.uploadForm.submit();
    ...
    The problem I'm facing, is that whenever I issue a submit on my uploadForm, the data gets
    posted inside a new browser tab (in FF4) or a new browser window (Chrome) instead of
    within the specified/expected IFRAME.

    PS1: I had to specify an empty contentsURL property otherwise the HTMLFlow would render as a DIV instead of an IFRAME.
    PS2: I had to override the getIFrameHTML because the IFRAME ID property would not render.

    Anyone know why the submit action doesn't take place in the IFRAME as it should?

    Thanks,

    #2
    Don't attempt to use the built-in Iframe feature of HTMLFlow or override the (internal) getIframeHTML function. Just provide an HTML for an Iframe as normal HTMLFlow.contents.

    Comment


      #3
      Thanks,

      I'll try that ... Although, in the mean time I found out that the target attribute on the form element
      is now deprecated ... Can you confirm this?

      If so, I think I'll have to have my <FORM> element embedded within the actual <IFRAME> so that I can
      omit the targe attribute altogether.

      To your knowledge, is that required?

      Thanks,

      Comment


        #4
        Where are you seeing target as deprecated? It's not deprecated, it's just not needed if you're using our server. No, no need to try to stick the whole form into an IFRAME.

        Comment


          #5
          I know W3Schools is not the best reference there is, but that's where I found the following ...

          ---------------------------

          Compatibility Notes

          The target attribute of <form> is deprecated, and is not supported in HTML 4.01 Strict / XHTML 1.0 Strict DTD.

          ---------------------------

          Can be seen @ http://www.w3schools.com/TAGS/att_form_target.asp


          Let me know what you think,
          Thanks!

          Comment


            #6
            Yes, target is deprecated because frames are deprecated, which is so absurd it's kind of a running joke. Please ignore it.

            Comment


              #7
              Thanks,

              I'll try the proposed approach: an explicit <IFRAME> specified
              within the contents attribute of my HTMLFlow.

              I'll follow up tomorrow with my results/findings.

              Thanks for the assistance,

              Comment


                #8
                Works perfectly with the proposed approach. Thanks!

                Comment

                Working...
                X