Announcement

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

    getFileURL returning NULL

    SmartClient Version: v8.3p_2013-04-05/PowerEdition Deployment (built 2013-04-05)

    I'm trying to use datasource.getFileURL(record) to get a URL to use in an IMG. It's returning null and I'm looking for suggestions on what I may be missing. At the same point in my client code, I tried calling datasource.viewFile(record) using the same datasource and record - that works correctly which I interpret to mean that my ds.xml definition is OK and my images are stored in the database properly.

    I was previously (sucessfully) fetching these images using the "encodeInResponse" option but have a need to support larger files in IE8.

    My ds.xml:

    Code:
    <DataSource
        dbName="SQLServer"
        tableName="map"
    	ID="map"
    	serverType="sql"
    	serverConstructor="com.ricoh.mdm.cm.admintool.server.datasource.MapDataSource">
    	
    	<fields>
    		<field primaryKey="true" name="map_id" hidden="true" type="sequence"></field>
    		<field name="map_name" type="ntext" length="255" required="true"></field>
    		<field name="map_description" type="ntext" length="511"></field>
    		<field name="map_filename" type="ntext" length="512" required="true"></field>
    		<field name="map_parent_id" type="number"></field>
    		<field name="map_parent_x" type="number"></field>
    		<field name="map_parent_y" type="number"></field>
    		<field name="dev_group_type_id" type="number" required="true"></field>
    		<field name="dev_group_id" type="number" required="true"></field>
    		<field name="map_image" type="imageFile"></field>
    	</fields>
    	
    	<operationBindings>
    		<operationBinding operationType="viewFile" requiresRole="readonly"  operationGroup="DeviceBasicRead">
    		</operationBinding>	
    		<operationBinding operationType="fetch" requiresRole="readonly"  operationGroup="DeviceBasicRead">
    		</operationBinding>	
    		<operationBinding operationType="add" requiresRole="admin"  operationGroup="DeviceBasicWrite" groupRestricted="true" >
    		</operationBinding>	
    		<operationBinding operationType="update" requiresRole="admin"  operationGroup="DeviceBasicWrite" groupRestricted="true" >
    		</operationBinding>	
    		<operationBinding operationType="remove" requiresRole="admin"  operationGroup="DeviceBasicWrite" groupRestricted="true" >
    		</operationBinding>	
    	</operationBindings>
    </DataSource>
    I have tried removing the serverConstructor attribute with no change in behaviour.

    I would normally include a showcase-type sample but this will be difficult given the database requirement.

    Thanks,

    Matt

    #2
    There are very few ways this codepath can end up returning early, and all of them are basically related to clientOnly DataSources, cacheAllData:true DataSources or dataProtocol:"clientCustom" - are you using any of these settings?

    Comment


      #3
      More details

      After long investigation I've discovered the culprit of the behaviour:
      Code:
      	/**
      	 * JSNI Method to apply a "login_token" parameter to every RPC request SmartClient sends
      	 * 
      	 * @param loginToken
      	 */
      	private static native void applyLoginTokenToRPCManager( String loginToken ) /*-{
      		if ($wnd.isc.RPCManager._sendRequest == null) {
      			$wnd.isc.RPCManager.addClassMethods({
      				_sendRequest : $wnd.isc.RPCManager.sendRequest
      			});
      			$wnd.isc.RPCManager
      					.addClassMethods({
      						sendRequest : function(request) {
      							if (this._loginToken != null && request != null) {
      								if (request.params == null)
      									request.params = {};
      								request.params.login_token = this._loginToken;
      
      							}
      							this._sendRequest(request);
      						}
      					});
      		}
      		$wnd.isc.RPCManager._loginToken = loginToken;
      
      	}-*/;
      This is code that was written about 3 years ago (I'm told this was given to us by Isomorphic). Its intent is to insert our login token to each request to the server.

      I found that even if I don't do this for the datasource requests that are failing for getFileURL() (but continue to do it for all others), the getFileURL() still returns null.

      For now, I've changed the code to put the login token into a cookie instead and things appear to be working OK. Does this seem OK? I'm not sure why a cookie wasn't used in the first place. Can you tell me why this code would impact getFileURL()?

      Any insight would be appreciated.

      Thanks!

      Matt

      Comment


        #4
        This doesn't look like something we would have provided, as you can get the same effect by just setting the default RPCManager.actionURL without the need for an override like this.

        This code would break getFileURL() (and a few other APIs) because the replacement sendRequest() method does not return the value of the original sendRequest method.

        Comment

        Working...
        X