Announcement

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

    Facing Issue with file Upload

    I'm using Licenced version of 70RC2a of SC. need to implement file upload in database and render as grid like in upload example of SC.

    I've crated an datasource name attachDS.ds.xml as follows.
    Code:
    <DataSource>
    	<ID>attachDS</ID>
    	<title>Attachement</title>
    	<serverType>generic</serverType>
    	<showPrompt>false</showPrompt>
    	<primaryKeyField>dbid</primaryKeyField>
    	<pluralTitle>Attachement</pluralTitle>
    	<subTabTitle>Attachement</subTabTitle>
    	<titleField>title</titleField>
    		
      <fields>
    	<field>
        	<name>dbid</name>
        	<title>dbid</title>
        	<type>long</type>
        	<primaryKey>true</primaryKey>
        	<hidden>true</hidden>
        	<canEdit>false</canEdit>
        	<length>10</length>
        </field>
        <field>
        	<name>title</name>
        	<title>Title</title>
        	<type>text</type>
        	<required>true</required>
    	<wrap>true</wrap>
        </field>
        <field>
        	<name>targetfile</name>
        	<title>File</title>
        	<type>imageFile</type>
    	<required>true</required>
        	<maxFileSize>51200</maxFileSize>
        </field>
    	</fields>
    	
    	<serverObject lookupStyle="spring" bean="attachDMI" />
    	<operationBindings>
    		<binding operationType="fetch" serverMethod="get">
    		<serverObject lookupStyle="spring" bean="attachDMI" />
    		</binding>
    		<binding operationType="add" serverMethod="post">
    		<serverObject lookupStyle="spring" bean="attachDMI" />
    		</binding>
    		
                              <binding operationType="remove" serverMethod="delete">
    		<serverObject lookupStyle="spring" bean="attachDMI"/>
    		</binding>
    	</operationBindings>
    </DataSource>
    Having a attachPane code as follows.
    Code:
    /*
    * attachPane form code snippet
    */
    
    	this.form = isc.DynamicForm.create({            
    				name:"uploadForm",
    				encoding:"multipart",
    				canSubmit:true,
    				autoFetchData:false,
    				dataSource:"attachDS",
    				layoutAlign:"center",
    				autoDraw:false,
    			             cellPadding: 4,            
    				titleOrientation: "left",
    				wrapItemTitles:"false",
    			             fields: [] // these fields will     automatically populate on page from DS
    			         });
    Following is the button which is used for upload.
    Code:
    /*
    * the datasource pointing here is above datasource creates two fields title and upload binary file with brouse button and submit button.
    */
    click : function() {
    	attachPane.form.saveData(null, {params: {singleUpload: true}});
    	attachPane.form.editNewRecord();
    	}
    I'm not getting any error on firebug or SC console. But it is not hitting the DMI method on server. nothing happening.

    If I change the "type" in datasource of targetfile field to 'text' from 'imageFile' it is immideately hits the post method of DMI.

    I've gone through complete documentation of upload and multifile upload.

    Please suggest as I'm not able to move forward a bit.
    Attached Files

    #2
    You say that this is working for you when the field type is "imageFile", but failing when the type is "text".
    "text" is not a valid field type for a binary field -- instead you should be setting type to "binary".

    If that doesn't resolve it, can you post the latest code -- ideally complete code for the datasource and simple client-side code that will allow us to reproduce the problem on our end?

    Thanks
    Isomorphic Software

    Comment


      #3
      issue with imageFile/binary type

      nope!!

      I mean to say it is not hitting the server method if type is imageFile or binary. If I change the type as text only then it is hitting the server.

      See the following code snippet.

      Code:
      <field>
          	<name>targetfile</name>
          	<title>File</title>
          	<type>imageFile</type>
      	<required>true</required>
          	<maxFileSize>51200</maxFileSize>
      </field>
      and I need to upload the Image files. Relevent Code and screen shot is already pasted in previous conversation (see above postings).

      Comment


        #4
        Ok - we'll take a look at this - does the Feature Explorer Upload sample work for you?

        If so, can you post the entire source for the dialog in your screenshot, or a full example we can run

        Also, why are you specifying fields: [] on your dynamicForm?

        Comment


          #5
          The fields:[] is written because the fields are populating through the datasource file.

          The example given is working fine in my isomorphic folder.

          Following is the code snippet calling the the files attached here.

          On click of the following toolstrip button it is calling a method showAttachementsPane of file method.js. Inside this method it is creating attachementPane by calling another file AttachementPane.js. Datasource file attachementsDS.ds.xml is also attached.
          Code:
          this.attachmentsTileGrid.toolStrip.uploadButton.click = function(){
                  	//alert("Upload file");
                  	xxxx.FileName.showAttachementsPane(attachementsDS);	  // passing name of datasource
                  },

          Code is not showing any error on the console or firebug.

          Pls suggest.
          Attached Files

          Comment


            #6
            Equivalent code is working fine here. How are you determining that no request reaches the server? Use the "Net" panel in Firebug or Fiddler to check.

            Comment


              #7
              I have already written above, I'm not getting any request line on fireBug. As well as see the attached console line.
              Attached Files

              Comment


                #8
                Hi Ashish,

                We're running your exact code against 7.0rc2.

                What I did was:
                - add the dataSource file to smartclientSDK\shared\ds\
                - add the 2 js files you sent over to a new directory I created for this test: smartclientSDK\examples\TESTS
                - modified the method.js file to attach the method to an object (foo) -- see attachment
                - made a bootstrap jsp file which loaded Isomorphic, loaded the dataSource and the 2 .js files, and then called the method on the object (foo)
                Code:
                <script src="AttachementPane.js"></script>
                <script src="method.js"></script>
                <script>
                <isomorphic:loadDS ID="attachementsDS"/>
                  
                  foo.showAttachementsPane("attachementsDS", null);
                
                </script>
                If I then run this code by doing startEmbeddedServer.bat and navigating to localhost:8080/examples/TESTS/method.isc I see a window with a form with 2 fields, "Title" and "File"
                If I enter an arbitrary title ("aaa", say) and select a file from my hard drive and hit the button entitled "Done", I see an alert with the title I entered and the file name I selected, and then I see a request hit the server.
                You can see this in the logs which go to the console where I tripped 'startEmbeddedServer.bat' - the logs look like this:
                Code:
                === 2009-12-28 17:12:50,828 [sor7] DEBUG RPCManager - Request #1 (DSRequest) pay
                load: {
                    operationConfig:{dataSource:"attachementsDS", operationType:"add"},
                    componentId:"isc_DynamicForm_25",
                    appID:"builtinApplication",
                    operation:"attachementsDS_add",
                    oldValues:{},
                    criteria:{},
                    values:{
                        targetfile:"method.js",
                        title:"aaa",
                        _transaction:null,
                        targetfile_filesize:2257,
                        targetfile_filename:"method.js",
                        targetfile_date_created:new Date(1262049170828)
                    }
                }
                The server then throws an error (expected since I don't have back end code to support this dataSource), and I see a warning on the client "No bean named 'attachementsPocDMI' is defined".

                So for me, your code is behaving exactly as expected.

                Looking at your screenshot showing the RPC tab in the Developer console, it appears that a request has been put together and targetted at an appropriate URL (something like http://localhost:7001/ER3/isomorphic/IDACall which seems appropriate).
                If the "Net" tab of firebug is enabled for this application, I'd really expect to see a POST request to IDACall. If this isn't happening for you there must be something else in your application code which is changing this (or you must be running a different SmartClient version to what I have locally).

                Since the other sample is working for you I think it's most likely that you either have some other code in your app which is changing the behavior of this, or the request is going through but the net tab was not enabled or similar, so you weren't seeing it.

                Can you double check that you really aren't seeing any true request go through in firebug and that you don't get any server logs indicating a submission?

                If you find the request really isn't being submitted, I think we'll need to see a full standalone test case demonstrating the problem since we're not reproducing it on our end.
                Thanks
                Isomorphic Software
                Attached Files

                Comment


                  #9
                  I am getting below exception even before it reaches to my service using the same code:

                  === 2009-12-29 13:23:27,765 [ng)'] INFO RequestContext - URL: '/ER3/ias/er/view/ComplexNewFormPane.js', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)': Moz (Gecko) with Accept-Encoding header
                  === 2009-12-29 13:23:28,500 [ng)'] INFO RequestContext - URL: '/ER3/content/contentPage.htm', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)': Moz (Gecko) with Accept-Encoding header
                  === 2009-12-29 13:23:36,828 [ng)'] INFO RequestContext - URL: '/ER3/isomorphic/IDACall', User-Agent: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)': Moz (Gecko) with Accept-Encoding header
                  === 2009-12-29 13:23:36,859 [ng)'] DEBUG XML - Parsed XML from (in memory stream): 0ms
                  === 2009-12-29 13:23:36,859 [ng)'] DEBUG RPCManager - Processing 1 requests.
                  === 2009-12-29 13:23:36,875 [ng)'] ERROR IDACall - Top-level servlet error:
                  java.lang.NullPointerException
                  at com.isomorphic.datasource.DSRequest.parseUploadedFiles(DSRequest.java:336)
                  at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:319)
                  at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:1235)
                  at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:234)
                  at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:90)
                  at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
                  at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
                  at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                  at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                  at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                  at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:248)
                  at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
                  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
                  at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
                  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                  at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:216)
                  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                  at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
                  at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                  at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilte

                  This may give you a idea of what's missing

                  Thanks,
                  Ashish Chugh.

                  Comment


                    #10
                    Not sure how to reconcile this with your previous reports of there not being a request at all.

                    You clearly are not actually using the code that you are showing us, since that works perfectly. You need to troubleshoot the code you haven't shared.

                    Comment


                      #11
                      I am using the same code, I checked the smartClientServerLog.txt file in my server and I found this exception and because NullPointerException is coming in DSResquest itself, that means request is not processed, this is what we have told you before.

                      I have send this exception earlier also but through mail.

                      Thanks,
                      Ashish Chugh.
                      Last edited by achugh; 29 Dec 2009, 14:48.

                      Comment


                        #12
                        I see, in previous post ashishbg has mentioned that he can not see the request through firebug but he attached the developer console image with the incomplete request. There must be some issue with firebug at that time but I can see the request in firebug also and with NET tab enabled.

                        Below is the POST tab of request in firebug:

                        Content-Type: multipart/form-data; boundary=---------------------------222792270112193
                        Content-Length: 73449

                        -----------------------------222792270112193
                        Content-Disposition: form-data; name="targetfile"; filename="err.gif"
                        Content-Type: image/gif

                        GIF89a��÷�����€���€�€€���€€�€�€€€€€ÀÀÀÿ���ÿ�ÿÿ���ÿÿ�ÿ�ÿÿÿÿÿ���������������������������������������3��f��™��Ì��ÿ�3��33�3f�3™�3Ì�3ÿ�f��f3�ff�f™�fÌ�fÿ�™��™3�™f�™™�™Ì�™ÿ�Ì��Ì3�Ìf�Ì™�ÌÌ�Ìÿ�ÿ��ÿ3�ÿf�ÿ™�ÿÌ�ÿÿ3��3�33�f3�™3�Ì3�ÿ33�33333f33™33Ì33ÿ3f�3f33ff3f™3fÌ3fÿ3™�3™33™f3™™3™Ì3™ÿ3Ì�3Ì33Ìf3Ì™3


                        -----------------------------222792270112193
                        Content-Disposition: form-data; name="_transaction"

                        <transaction xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:type="xsd:Object"><transactionNum xsi:type="xsd:long">0</transactionNum><operations xsi:type="xsd:List"><elem xsi:type="xsd:Object"><values xsi:type="xsd:Object"><targetfile>err.gif</targetfile><title>err</title></values><operationConfig xsi:type="xsd:Object"><dataSource>attachementsDS</dataSource><operationType>add</operationType></operationConfig><componentId>isc_DynamicForm_54</componentId><appID>builtinApplication</appID><operation>attachementsDS_add</operation><oldValues xsi:type="xsd:Object"></oldValues></elem></operations><jscallback>parent.isc.Comm.hiddenFrameReply(0,results)</jscallback></transaction>
                        -----------------------------222792270112193--


                        Below is the RESPONSE tab of request in firebug:

                        <BR>com.isomorphic.servlet.IDACall top-level exception<BR>
                        <PRE>
                        java.lang.NullPointerException
                        at com.isomorphic.datasource.DSRequest.parseUploadedFiles(DSRequest.java:336)
                        at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:319)
                        at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:1235)
                        at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:234)
                        at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:90)
                        at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
                        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
                        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
                        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
                        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
                        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                        at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:248)
                        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
                        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
                        at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:216)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:181)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:108)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:195)
                        at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
                        at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
                        at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:90)
                        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
                        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
                        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
                        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
                        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
                        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
                        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
                        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
                        </PRE>


                        Thanks,
                        Ashish Chugh.

                        Comment


                          #13
                          Hi, first and foremost, thanks for you patience and help! I'm pretty sure we are using the same code we sent you. Is there a way for us to discuss this over the phone or, even better, have a webex session where I can show you exactly what is going on?

                          BTW: This is a big deal for us; we are targeting to be code complete by tomorrow and this is the only remaining feature! Your assistance to help us out of this would be amazingly welcome.

                          Ashish Chugh

                          Comment


                            #14
                            This could happen if you skipped steps in the Deployment Instructions, specifically, not installing the Init servlet or not copying server.properties into your deployment.

                            Follow all the documented steps, don't skip any.

                            Comment


                              #15
                              Hi,

                              Checked again the setup and the deployment instructions. We do have all the correct settings but still it seems that we are getting the config object as null at line 336 in DSRequest.

                              int maxSize = config.getInt("DSRequest.maxUploadFileSize", 0);

                              Please let us know what else we should be looking for to FIX this issue ?

                              Thanks,
                              Ashish Chugh

                              Comment

                              Working...
                              X