Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30th Dec 2009, 17:48
jay.l.fisher jay.l.fisher is offline
Registered Developer
 
Join Date: Oct 2009
Posts: 979
Default 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.
Reply With Quote
  #2  
Old 31st Dec 2009, 10:20
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,540
Default

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?
Reply With Quote
  #3  
Old 31st Dec 2009, 17:02
jay.l.fisher jay.l.fisher is offline
Registered Developer
 
Join Date: Oct 2009
Posts: 979
Default

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?
Reply With Quote
  #4  
Old 2nd Jan 2010, 17:15
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,540
Default

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.
Reply With Quote
  #5  
Old 2nd Jan 2010, 19:50
jay.l.fisher jay.l.fisher is offline
Registered Developer
 
Join Date: Oct 2009
Posts: 979
Default

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.
Reply With Quote
  #6  
Old 4th Jan 2010, 12:22
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,540
Default

Not sure why you can't find it - here it is.
Reply With Quote
  #7  
Old 5th Feb 2010, 09:43
KsmrtgwtDev KsmrtgwtDev is offline
Registered Developer
 
Join Date: Feb 2010
Posts: 3
Default Displaying Image

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

The above stated link is the api doc and not the example.
Reply With Quote
  #8  
Old 14th Jun 2010, 02:06
somewhereinbelgium somewhereinbelgium is offline
Registered Developer
 
Join Date: Feb 2010
Posts: 74
Default

Quote:
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
Reply With Quote
  #9  
Old 14th Jun 2010, 05:35
jay.l.fisher jay.l.fisher is offline
Registered Developer
 
Join Date: Oct 2009
Posts: 979
Default

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().
Reply With Quote
  #10  
Old 14th Jun 2010, 13:35
somewhereinbelgium somewhereinbelgium is offline
Registered Developer
 
Join Date: Feb 2010
Posts: 74
Default

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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved