You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Bob Harner (JIRA)" <ji...@apache.org> on 2012/09/17 03:42:07 UTC

[jira] [Commented] (TAP5-1903) Bug that affects the javascript when a zone which contains an upload component is re render

    [ https://issues.apache.org/jira/browse/TAP5-1903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456723#comment-13456723 ] 

Bob Harner commented on TAP5-1903:
----------------------------------

I applied the patch and committed to master but am having Git problems trying to get it into the 5.3 branch, hopefully fixed soon.
                
> Bug that affects the javascript when a zone which contains an upload component is re render 
> --------------------------------------------------------------------------------------------
>
>                 Key: TAP5-1903
>                 URL: https://issues.apache.org/jira/browse/TAP5-1903
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-upload
>    Affects Versions: 5.3.2, 5.3.3, 5.3.4, 5.3.5
>            Reporter: Boris Horvat
>            Assignee: Bob Harner
>            Priority: Minor
>              Labels: ajax, javascript, jquery, upload
>         Attachments: javascript_upload_rerender.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> I have run into an issue with javascript that runs after the zone which contains an upload component is re rendered. The code would look like this
>  <t:zone t:id="zone">
>           <t:form t:id="form">
>                 <input t:type="upload" t:value="value" />
>            </t:form>                
>  </t:zone>
> once this is rendered the javascript would send an error TypeError: Cannot set property 'enctype' of undefined [http://localhost:8080/assets/0.55-SNAPSHOT/jquery/tapestry-jquery.js:904] 
> what happens is that once the ajax starts to work the Upload component (Upload.java) sends the code that is to be executed 
> Tapestry.Initializer.injectedUpload = function(element) 
> { 
>     var form = $(element).form; 
>     form.enctype = "multipart/form-data"; 
>     form.encoding = "multipart/form-data"; 
> } 
> $(element).form returns null for partial updates. 
> the code for that can be found https://github.com/apache/tapestry5/blob/trunk/tapestry-upload/src/main/resources/org/apache/tapestry5/upload/components/upload.js
> the solution that worked for me is 
> Tapestry.Initializer.injectedUpload = function(element) 
> { 
>    var form = $(element).form; 
>    if(form){ 
>       form.enctype = "multipart/form-data"; 
>       form.encoding = "multipart/form-data"; 
>    } 
> } 
> two more thing that are maybe worth to mention is that I was using tapestry-jquery plugin (but since this code comes from the tapestry core and it has nothing to do with jquery I think that it is irrelevant). the second thing is that the reason this error shows up is because what is send from the ajax (along with the code that is to be executed in javascript) is the list of components (in my case it was a list of 6) 5 textfields and 1 upload. All of them apart from upload where return as objects the upload was returned from ajax was a string which is why the 
>  var form = $(element).form; 
> is not working and the solution about works
> One other thing to mention is that this error does not affect java code only the javascript since an error is thrown so javascript stops to work on the page
> the discussion on the forum can be found here  http://tapestry.1045711.n5.nabble.com/Zone-refresh-image-uplaod-td5631622.html#a5634387

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira