Announcement

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

    binary field and queue

    Be sure your post includes:

    1. the *complete* SmartGWT or SmartClient version from the lower left-hand corner of the Developer Console (see FAQ for how to open Developer Console), for example, \"v8.2p_2012-04-18/PowerEdition Deployment\"
    SmartGWT EE 3.1p and 4.0d;
    SmartClient Version: v8.3p_2013-04-23/EVAL Deployment (expires 2013.06.22_13.01.10) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    2. browser(s) and version(s) involved
    firefox 22.0

    3. for a server-side problem, the *complete* logs generated during processing of the failing request (do *not* trim to just the error message)

    4. for any problem processing a server response, the actual response as shown in the RPC tab in the Developer Console

    5. if there is a JavaScript error, the stack trace logged in the Developer Console (see FAQ)

    6. sample code if applicable
    ds.xml:
    Code:
    <DataSource 
    	dbName="Mysql"
    	tableName="organization_info"
    	ID="organization_info"
    	dataSourceVersion="1"
    	generatedBy="v8.3p_2013-04-23/EVAL Deployment 2013-04-23"
    	serverType="sql"
    >
    	<fields>
    		<field   primaryKey="true"  hidden="true" autoGenerated="true"  nativeName="organization_info_id"      name="organization_info_id" length="36" type="text"></field>
    		<field title="file"  name="FileItem0"  type="binary"></field>
    		<field title="filename" ignore="true" name="FileItem0_filename"  type="text"></field>
    		<field title="filesize" ignore="true" name="FileItem0_filesize"  type="text"></field>
    		<field title="date_created" ignore="true" name="FileItem0_date_created"  type="text"></field>
    	</fields>  
    	
    	<operationBindings>
    	
    	<operationBinding operationType="add">
    	<serverObject className="cn.gov.nsccsz.server.DMIHandler" methodName="doUUIDAdd"/> 
    	</operationBinding>	
    	</operationBindings>         
    </DataSource>
    main.ui.xml:
    Code:
    <DynamicForm ID="DynamicForm9" dataSource="organization_info" autoDraw="false">
        <fields>
            <FormItem name="FileItem0" constructor="FileItem"/>
        </fields>
    </DynamicForm>
    
    
    <DynamicForm ID="DynamicForm3" dataSource="organization_info" autoDraw="false">
        <fields>
            <FormItem name="FileItem0" constructor="FileItem"/>
        </fields>
    </DynamicForm>
    client java code:
    Code:
    		IButton  buttonnew = (IButton)Canvas.getById("New");
    		buttonnew.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				final DynamicForm  form3 = (DynamicForm)Canvas.getById("DynamicForm3");
    				final DynamicForm  form9 = (DynamicForm)Canvas.getById("DynamicForm9");
    				RPCManager.startQueue(); 
    		
    				form3.saveData();
    				form9.saveData();
    				RPCManager.sendQueue();
    				
    			}
    		});
    Posts with incomplete information are much more likely to be ignored.



    Hello,
    I choose a file in dynamicform3 and another file in dynamicform9, then press buttonnew, the two files was inserted into database successfully, but in developer console, the two dsrequest wasn't in a queue, what should i do to make them in a queue?

    #2
    It's not possible to queue upload requests from two different forms. The binary fields must be in the same form.

    See also MultiUploadItem for a different presentation of multiple file upload.

    Comment


      #3
      Hi, what should i do to make more than one upload requests in a queue?
      I think MultiUploadItem don't match my need because it can't upload two file into two different binary fields in *one* datasource.
      i tried two binary fields in the same form, and the following is the result:

      version: smartgwtee-3.1p,
      we do test the code in the latest 4.0p, the result is same as the following:
      SmartClient Version: v8.3p_2013-02-04/EVAL Deployment (expires 2013.04.05_09.12.40) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)
      (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

      client code:
      Code:
                      final DataSource dataSource = DataSource.get("SQS_CLQD");
      
      		HiddenItem parentIdItem = new HiddenItem("PARENT_ID");
      		parentIdItem.setValue("" + System.currentTimeMillis());
      
      		final DynamicForm kxxbgForm = new DynamicForm();
      		kxxbgForm.setDataSource(dataSource);
      		kxxbgForm.setWidth(800);
      		kxxbgForm.setColWidths("700", "100");
      
      		final DynamicForm hzxyForm = new DynamicForm();
      		hzxyForm.setDataSource(dataSource);
      		hzxyForm.setWidth(800);
      		hzxyForm.setColWidths("700", "100");
      
      		final DynamicForm zmclForm = new DynamicForm();
      		zmclForm.setDataSource(dataSource);
      		zmclForm.setWidth(800);
      		zmclForm.setColWidths("700", "100");
      
      		TextItem zzjgmItem = new TextItem("ZZJGM");
      		TextItem yyzzItem = new TextItem("YYZZ");
      ;
      
      		FileItem kxxbgItem = new FileItem("KXXBG");
      		FileItem hzxyItem = new FileItem("HZXY");
      
      		IButton saveItem = new IButton("保存");
      		saveItem.setAlign(Alignment.CENTER);
      		saveItem.addClickHandler(new ClickHandler() {
      			public void onClick(ClickEvent event) {
      				RPCManager.startQueue();
      				
      				kxxbgForm.saveData();
      				
      				RPCManager.sendQueue(); // no working
      			}
      		});
      
      		kxxbgForm.setFields(parentIdItem, zzjgmItem, yyzzItem,kxxbgItem,hzxyItem);
      
      		VLayout topLayout = new VLayout();
      		topLayout.setMembers(kxxbgForm,saveItem);
      
      		return topLayout;
      ds.xml:
      Code:
      <DataSource 
      	schema="PUBLIC"
      	dbName="HSQLDB"
      	tableName="SQS_CLQD"
      	ID="SQS_CLQD"
      	serverType="sql"
      >
      	<fields>
      		<field name="ID" hidden="true" primaryKey="true" type="sequence"></field>
      		<field sqlType="varchar" sqlLength="255" name="PARENT_ID" length="255" type="text" hidden="true"></field>
      		<field sqlType="varchar" sqlLength="255" name="ZZJGM" length="255" type="text" title="复印件1"></field>
      		<field sqlType="varchar" sqlLength="255" name="YYZZ" length="255" type="text" title="复印件2"></field>
      		<field sqlType="varchar" sqlLength="255" name="FRDB" length="255" type="text" title="复印件3"></field>
      		<field sqlType="varchar" sqlLength="255" name="SWDJ" length="255" type="text" title="复印件4"></field>
      		<field sqlType="varchar" sqlLength="255" name="WSZM" length="255" type="text" title="复印件5"></field>
      		<field sqlType="varchar" sqlLength="255" name="CWSJ" length="255" type="text" title="复印件6"></field>
      		<field sqlType="varchar" sqlLength="255" name="KXXBG" type="binary" customSQL="true" title="原件7"></field>
      		<!-- <field sqlType="varchar" sqlLength="255" name="KXXBG_file" length="255" type="text"></field> -->
      		<field sqlType="varchar" sqlLength="255" name="HZXY" type="binary" customSQL="true" title="原件8"></field>
      		<field sqlType="varchar" sqlLength="255" name="ZMCL" type="binary" customSQL="true" title="复印件9"></field>
      	</fields>
      	
      	<operationBindings>
          	<binding operationType="downloadFile" serverMethod="downloadFile">
              	<serverObject lookupStyle="new" className="com.most.server.dmi.FileUploadDMI"/>
              </binding>
              <binding operationType="add" serverMethod="add">
              	<serverObject lookupStyle="new" className="com.most.server.dmi.FileUploadDMI"/>
              </binding>
              <binding operationType="update" serverMethod="update">
              	<serverObject lookupStyle="new" className="com.most.server.dmi.FileUploadDMI"/>
              </binding>
              <binding operationType="viewFile" serverMethod="viewFile">
              	<serverObject lookupStyle="new" className="com.most.server.dmi.FileUploadDMI"/>
              </binding>
          </operationBindings>
           <!-- <valuesClause>(ZZJGM,KXXBG,HZXY,ZMCL) VALUES($values.ZZJGM,$values.KXXBG, 'file2','file2')</valuesClause> -->
      </DataSource>
      Code:
      === 2013-07-18 01:35:19,222 [l0-2] INFO  RequestContext - URL: '/showcase/sc/IDACall', User-Agent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)': MSIE with Accept-Encoding header, ready for compressed JS
      === 2013-07-18 01:35:19,226 [l0-2] DEBUG IDACall - Header Name:Value pair: Accept:text/html, application/xhtml+xml, */*
      === 2013-07-18 01:35:19,226 [l0-2] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997
      === 2013-07-18 01:35:19,226 [l0-2] DEBUG IDACall - Header Name:Value pair: Accept-Language:zh-CN
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Content-Type:multipart/form-data; boundary=---------------------------7ddcd13150d20
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Content-Length:4080
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Connection:Keep-Alive
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - Header Name:Value pair: Cookie:GLog=%7B%0D%20%20%20%20left%3A-4%2C%20%0D%20%20%20%20top%3A28%2C%20%0D%20%20%20%20width%3A1596%2C%20%0D%20%20%20%20height%3A805%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20trackRPC%3Atrue%0D%7D; isc_cState=ready
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - session exists: null
      === 2013-07-18 01:35:19,227 [l0-2] DEBUG IDACall - remote user: null
      === 2013-07-18 01:35:19,252 [l0-2] DEBUG XML - Parsed XML from (in memory stream): 1ms
      === 2013-07-18 01:35:19,255 [l0-2] DEBUG XML - Parsed XML from D:\workspace4.2\SmartGwtEE_showcase\war\showcase\sc\system\schema\List.ds.xml: 1ms
      === 2013-07-18 01:35:19,256 [l0-2] DEBUG RPCManager - Processing 1 requests.
      === 2013-07-18 01:35:19,266 [l0-2] WARN  DSRequest - We found a filename in the values for DataSource 'SQS_CLQD', field 'HZXY', but the expected corresponding binary content in the request body was missing.  Maybe a Filter or a framework like Struts has removed it?
      === 2013-07-18 01:35:19,266 [l0-2] INFO  DSRequest - We parsed 1 uploaded file(s): "C:/Users/ysb/Desktop/新建文本文档.txt" (2623 bytes)
      === 2013-07-18 01:35:19,268 [l0-2] ERROR IDACall - Top-level servlet error: 
      java.lang.ArrayIndexOutOfBoundsException: -26
      	at org.apache.commons.codec.binary.Base64.isBase64(Base64.java:137)
      	at org.apache.commons.codec.binary.Base64.discardNonBase64(Base64.java:478)
      	at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:374)
      	at com.isomorphic.util.DataTools.base64Decode(DataTools.java:4805)
      	at com.isomorphic.datasource.DSRequest.decodeUploadedStrings(DSRequest.java:665)
      	at com.isomorphic.datasource.DSRequest.<init>(DSRequest.java:543)
      	at com.isomorphic.rpc.RPCManager.parseRequest(RPCManager.java:1994)
      	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:284)
      	at com.isomorphic.rpc.RPCManager.<init>(RPCManager.java:269)
      	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:133)
      	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:74)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
      	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
      	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
      	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
      	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      	at org.mortbay.jetty.Server.handle(Server.java:324)
      	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
      === 2013-07-18 01:35:19,269 [l0-2] INFO  Compression - /showcase/sc/IDACall: 2652 -> 727 bytes
      Last edited by xu; 17 Jul 2013, 19:05. Reason: clarify

      Comment


        #4
        You cannot combined two uploads in a queue. You can include two binary fields in a single form and so upload them together - to do so, however, you need to use UploadItem, not FileItem, and you can fetch the individual files via the server-side API dsRequest.getUploadedFile(String fieldName).

        You'll note on the docs for UploadItem that, due to browser limitations, they are a bit tricky to work with. That's why we recommended MultiUploadItem if you want to upload multiple files.

        Comment

        Working...
        X