Announcement

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

    showFileInline="true" has no effect

    I'm trying to get an imageFile field to display the image in a ListGrid. Here is my datasource. The ListGrid that uses this as it's data source shows the image name with the View and Download icons whether I have the showFileInline tag set in the data source or not. I'm not defining any fields for the grid, just setting the data source and letting it dictate the grid fields.
    Code:
    <DataSource ID="ProductContent" dataFormat="iscServer"
    	serverType="sql" dbName="as400" tableName="ProductContent">
    	<fields>
    		 <field name="DPRPRD" title="Product" type="text" length="7" primaryKey="true" canEdit="false"/>
    		 <field name="NAME" title="Name" type="text" length="256"/>
    		 <field name="IMAGE" title="Image" type="imageFile" maxFileSize="204800" showFileInline="true"/>
    		 <field name="DESCRIPTION" title="Description" type="text" length="2048"/>
    	</fields>
    </DataSource>
    And a related issue is that, when I click the View icon, nothing happens. The server console shows the following each time I click the View icon.
    Code:
    === 2009-12-30 20:41:11,981 [0-12] INFO  RequestContext - URL: '/ipgui/sc/IDACall/base_media.jpeg', User-Agent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10': Safari with Accept-Encoding header
    === 2009-12-30 20:41:11,982 [0-12] WARN  RPCManager - client/server version mismatch.  Client is version: SC_SNAPSHOT-2009-12-17, server is version: 7.2_20091029 - mixing different client/server versions is generally not supported.  If you've installed a more recent client version, try clearing the browser cache and reloading the page.
    === 2009-12-30 20:41:11,983 [0-12] DEBUG XML - Parsed XML from (in memory stream): 1ms
    === 2009-12-30 20:41:11,984 [0-12] DEBUG RPCManager - Processing 1 requests.
    === 2009-12-30 20:41:11,984 [0-12] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"},
        operationConfig:{dataSource:"ProductContent", operationType:"viewFile"},
        appID:"builtinApplication",
        operation:"ProductContent_viewFile",
        oldValues:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"}
    }
    === 2009-12-30 20:41:11,985 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:11,985 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No public zero-argument method named '_ProductContent_viewFile' found, performing generic datasource operation
    === 2009-12-30 20:41:11,985 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:11,985 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2009-12-30 20:41:11,986 [0-12] INFO  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Performing fetch operation with
    	criteria: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}	values: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}
    === 2009-12-30 20:41:11,986 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_fieldname, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:11,986 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_filename, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:11,986 [0-12] WARN  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2009-12-30 20:41:11,986 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DriverManager fetching connection for as400 via jdbc url jdbc:as400:iwave;naming=system;prompt=false;user=IPGUI;password=IPGUI;libraries=*LIBL
    === 2009-12-30 20:41:11,986 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Passing JDBC URL only to getConnection
    === 2009-12-30 20:41:12,682 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Returning pooled Connection
    === 2009-12-30 20:41:12,682 [0-12] INFO  SQLDriver - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Executing SQL query on 'as400': SELECT ProductContent.IMAGE_filename, ProductContent.NAME, ProductContent.IMAGE_date_created, ProductContent.DESCRIPTION, ProductContent.IMAGE, ProductContent.DPRPRD, ProductContent.IMAGE_filesize FROM ProductContent WHERE (ProductContent.DPRPRD='#301987' AND ('1'='1') AND ('1'='1'))
    === 2009-12-30 20:41:13,484 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DSResponse: List with 1 items
    === 2009-12-30 20:41:13,485 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile] DSResponse: Map with 7 keys
    === 2009-12-30 20:41:13,489 [0-12] INFO  RequestContext - URL: '/ipgui/sc/IDACall/base_media.jpeg', User-Agent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10': Safari with Accept-Encoding header
    === 2009-12-30 20:41:13,490 [0-12] WARN  RPCManager - client/server version mismatch.  Client is version: SC_SNAPSHOT-2009-12-17, server is version: 7.2_20091029 - mixing different client/server versions is generally not supported.  If you've installed a more recent client version, try clearing the browser cache and reloading the page.
    === 2009-12-30 20:41:13,491 [0-12] DEBUG XML - Parsed XML from (in memory stream): 1ms
    === 2009-12-30 20:41:13,501 [0-12] DEBUG RPCManager - Processing 1 requests.
    === 2009-12-30 20:41:13,501 [0-12] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"},
        operationConfig:{dataSource:"ProductContent", operationType:"viewFile"},
        appID:"builtinApplication",
        operation:"ProductContent_viewFile",
        oldValues:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"}
    }
    === 2009-12-30 20:41:13,501 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:13,501 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No public zero-argument method named '_ProductContent_viewFile' found, performing generic datasource operation
    === 2009-12-30 20:41:13,502 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:13,502 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2009-12-30 20:41:13,502 [0-12] INFO  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Performing fetch operation with
    	criteria: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}	values: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}
    === 2009-12-30 20:41:13,502 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_fieldname, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:13,503 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_filename, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:13,503 [0-12] WARN  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2009-12-30 20:41:13,503 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DriverManager fetching connection for as400 via jdbc url jdbc:as400:iwave;naming=system;prompt=false;user=IPGUI;password=IPGUI;libraries=*LIBL
    === 2009-12-30 20:41:13,503 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Passing JDBC URL only to getConnection
    === 2009-12-30 20:41:14,223 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Returning pooled Connection
    === 2009-12-30 20:41:14,223 [0-12] INFO  SQLDriver - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Executing SQL query on 'as400': SELECT ProductContent.IMAGE_filename, ProductContent.NAME, ProductContent.IMAGE_date_created, ProductContent.DESCRIPTION, ProductContent.IMAGE, ProductContent.DPRPRD, ProductContent.IMAGE_filesize FROM ProductContent WHERE (ProductContent.DPRPRD='#301987' AND ('1'='1') AND ('1'='1'))
    === 2009-12-30 20:41:14,917 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DSResponse: List with 1 items
    === 2009-12-30 20:41:14,918 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile] DSResponse: Map with 7 keys
    === 2009-12-30 20:41:14,923 [0-12] INFO  RequestContext - URL: '/ipgui/sc/IDACall/base_media.jpeg', User-Agent: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10': Safari with Accept-Encoding header
    === 2009-12-30 20:41:14,924 [0-12] WARN  RPCManager - client/server version mismatch.  Client is version: SC_SNAPSHOT-2009-12-17, server is version: 7.2_20091029 - mixing different client/server versions is generally not supported.  If you've installed a more recent client version, try clearing the browser cache and reloading the page.
    === 2009-12-30 20:41:14,926 [0-12] DEBUG XML - Parsed XML from (in memory stream): 2ms
    === 2009-12-30 20:41:14,927 [0-12] DEBUG RPCManager - Processing 1 requests.
    === 2009-12-30 20:41:14,927 [0-12] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        criteria:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"},
        operationConfig:{dataSource:"ProductContent", operationType:"viewFile"},
        appID:"builtinApplication",
        operation:"ProductContent_viewFile",
        oldValues:{DPRPRD:"#301987", download_fieldname:"IMAGE", download_filename:"base_media.jpeg"}
    }
    === 2009-12-30 20:41:14,928 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:14,928 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile] No public zero-argument method named '_ProductContent_viewFile' found, performing generic datasource operation
    === 2009-12-30 20:41:14,928 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2009-12-30 20:41:14,928 [0-12] DEBUG AppBase - [builtinApplication.ProductContent_viewFile, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2009-12-30 20:41:14,928 [0-12] INFO  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Performing fetch operation with
    	criteria: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}	values: {DPRPRD:"#301987",download_fieldname:"IMAGE",download_filename:"base_media.jpeg"}
    === 2009-12-30 20:41:14,929 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_fieldname, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:14,929 [0-12] WARN  SQLWhereClause - [builtinApplication.ProductContent_viewFile, builtinApplication.null] no column name for field named: download_filename, field2ColumnMap: {IMAGE_filename:"IMAGE_filename", NAME:"NAME", IMAGE_date_created:"IMAGE_date_created",
     DESCRIPTION:"DESCRIPTION", IMAGE:"IMAGE", DPRPRD:"DPRPRD", IMAGE_filesize:"IMAGE_filesize"}
    === 2009-12-30 20:41:14,929 [0-12] WARN  SQLDataSource - [builtinApplication.ProductContent_viewFile, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2009-12-30 20:41:14,929 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DriverManager fetching connection for as400 via jdbc url jdbc:as400:iwave;naming=system;prompt=false;user=IPGUI;password=IPGUI;libraries=*LIBL
    === 2009-12-30 20:41:14,929 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Passing JDBC URL only to getConnection
    === 2009-12-30 20:41:15,627 [0-12] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Returning pooled Connection
    === 2009-12-30 20:41:15,627 [0-12] INFO  SQLDriver - [builtinApplication.ProductContent_viewFile, builtinApplication.null] Executing SQL query on 'as400': SELECT ProductContent.IMAGE_filename, ProductContent.NAME, ProductContent.IMAGE_date_created, ProductContent.DESCRIPTION, ProductContent.IMAGE, ProductContent.DPRPRD, ProductContent.IMAGE_filesize FROM ProductContent WHERE (ProductContent.DPRPRD='#301987' AND ('1'='1') AND ('1'='1'))
    === 2009-12-30 20:41:16,342 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile, builtinApplication.null] DSResponse: List with 1 items
    === 2009-12-30 20:41:16,343 [0-12] INFO  DSResponse - [builtinApplication.ProductContent_viewFile] DSResponse: Map with 7 keys
    If I click the download icon I get this error.
    Code:
    Safari can’t open the page “http://localhost:8888/ipgui/sc/IDACall/base_media.jpeg?isc_rpc=1&isc_v=SC_SNAPSHOT-2009-12-17&isc_tnum=15” because the network connection was reset. This problem can occur if either the server or the network connection is busy. Wait for a few minutes, and then try again.
    I've also tried it in Firefox and the behavior is basically the same except that clicking either the View or Download icons gets this error.
    Code:
    The connection was reset
    The connection to the server was reset while the page was loading.
        *   The site could be temporarily unavailable or too busy. Try again in a few moments.
        *   If you are unable to load any pages, check your computer's network           connection.
        *   If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

    #2
    On showFileInline - try setting this on the ListGridField instead.

    As far as the failed download, those logs look partial - either there should be further logs or an exception should be thrown. Are there further errors?

    Are you sure there's a valid file stored in that row?

    Did you generate this table using the DataSource wizard or did you create it by hand? If by hand, can you show the SQL schema you're using?

    Comment


      #3
      Setting showFileInline on the ListGridField made the difference. It is now attempting to show the image. I created the table by hand with this SQL (on an IBM iSeries).
      Code:
      CREATE TABLE R36MPSDTA/PRODUCTCONTENT (DPRPRD CHAR ( 7) NOT NULL   
      WITH DEFAULT, IMAGE BLOB ( 200 K), IMAGE_FILENAME VARCHAR ( 256),  
      IMAGE_FILESIZE INT , IMAGE_DATE_CREATED TIMESTAMP , NAME VARCHAR ( 
      256), DESCRIPTION FOR COLUMN DESCR VARCHAR ( 2048), CONSTRAINT     
      DPRPRD PRIMARY KEY (DPRPRD))
      I uploaded the image file into the row using a DynamicForm. It appeared to work OK. When I select the row from the table on the iSeries is says it contains a *POINTER to BLOB.

      I may decide switch to storing images separately as normal files in the file system if storing them in the DB proves problematic. I went down this path based on one of the SmartGWT samples. Is there an example of uploading a file into the file system rather than into a DB row?

      Comment


        #4
        If you want to store images as files, DSRequest.getUploadedFile() is how you get access to the InputStream for the file. To provide the file for viewing or downloading, return an InputStream under the name of the binary field in the data you provide to DSResponse.setData().

        It's not clear what this "connection reset" behavior is, but it sounds as though something other than SmartGWT is generating that error.

        Comment


          #5
          Can you provide an example of DSRequest.getUploadedFile()? I don't see any reference to it in the javadocs and I'm not clear how to implement it. What do the DS field and the DynamicForm item need to look like? An example would be terrific.

          Comment


            #6
            Not sure why you can't find it - here it is.

            Comment


              #7
              Displaying Image

              Could you please provide the sample for the DSRequest.getUploadFile().

              The above stated link is the api doc and not the example.

              Comment


                #8
                Originally posted by jay.l.fisher
                I may decide switch to storing images separately as normal files in the file system if storing them in the DB proves problematic. I went down this path based on one of the SmartGWT samples. Is there an example of uploading a file into the file system rather than into a DB row?
                Hi Jay,

                I realise that this was some months ago, but just wondered if you got the streaming via DSResponse.setData/InputStream technique to work? I also decided to have binary data persisted in the database (SQL Server in my case) but the case for this being a good idea becomes a little weak if I'm unable to get the byte stream being returned as an instance of InputStream.

                Any comments would be very much appreciated.

                Alastair

                Comment


                  #9
                  I ended up using a FileItem on the client form ...

                  FileItem imageUpload = new FileItem("IMAGE_UPLOAD", "Upload New Image");

                  On the server side if have a custom subclass of SQLDataSource that, among other things, gets the uploaded file as an input stream and writes it to disk.

                  ISCFileItem imageFile = req.getUploadedFile("IMAGE_UPLOAD");
                  InputStream in = imageFile.getInputStream();
                  etc.

                  I gave up on storing the images directly in the SQL table so I never tried sending the stream back via DSResponse.setData().

                  Comment


                    #10
                    Hi Jay,

                    Thanks for your useful feedback; it's definitely interesting that you chose ultimately not to persist to the database. For the uploading I'm using essentially the same technique and this is fine, but downloading the stream (really as a byte[]) is proving thus far elusive, so I'm using a funny technique which involves returning (from the server) the unique record id and then mapping that (client side) to a url which is returned from a value icon map. Mmmm...not really happy but it works.

                    Again, thanks for your time.

                    Alastair.

                    Comment

                    Working...
                    X