Controlling Which Webjects Get Uploaded BLOBs
When BLOBs are uploaded to Info*Engine from a web page or Info*Engine-based application, Info*Engine cannot determine which adapter webjects consume the BLOBs or how many BLOBs each webject should consume. By default, Info*Engine attempts to deliver all available BLOBs to the first adapter webject (any webject with a type of ACT or OBJ). Sometimes, the first adapter webject is not a webject that consumes BLOBs, so the default behavior of Info*Engine is not always appropriate.
To control how BLOBs are consumed by webjects, you can include the BLOB_COUNT parameter on any adapter webject. This parameter specifies how many BLOBs should be delivered to the adapter webject. You can specify a value of 0 when no BLOBs should be delivered to the webject. If you omit the BLOB_COUNT parameter, all remaining BLOBs are delivered to the webject.
The following UploadBlob.xml example task contains three adapter webjects. The first two webjects (Do-Sql) delete and add rows to a database table and do not use BLOBs. On these webjects, the BLOB_COUNT parameter is set to 0. The third webject (Put-Blob-Stream) is the webject that stores the BLOB and it has been defined to accept one BLOB. The values for the @FORM variables used in the parameters for the webjects can be supplied through a form like the form described in the previous section.
|
You must set the BLOB_COUNT parameter to 0 for every webject except for the webject you want the BLOBS to be delivered to.
|
The example task assumes that the database table contains the following columns:
• The NAME column contains the name of the BLOB.
• The FILECONTENT column contains the BLOB data.
The code for the example task is as follows:
<%@page language="java" session="false"%>
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie" %>
<!--
Upload a file from the browser and save in an oracle
blob column.
--/>
<ie:webject name="Do-Sql" type="ACT">
<ie:param name="INSTANCE" data="$(FORM[]instance[])"
default="jdbcAdapter"/>
<ie:param name="SQL"
data="DELETE FROM BLOBTEST WHERE NAME=
'$(FORM[]filename[0])'"/>
<ie:param name="CLASS" data="BLOBTEST"/>
<ie:param name="GROUP_OUT" data="TEMP"/>
<ie:param name="BLOB_COUNT" data="0"/>
</ie:webject>
<ie:webject name="Do-Sql" type="ACT">
<ie:param name="INSTANCE" data="$(FORM[]instance[])"
default="jdbcAdapter"/>
<ie:param name="SQL"
data="INSERT INTO BLOBTEST VALUES
('$(FORM[]filename[0])', EMPTY_BLOB())"/>
<ie:param name="CLASS" data="BLOBTEST"/>
<ie:param name="GROUP_OUT" data="TEMP"/>
<ie:param name="BLOB_COUNT" data="0"/>
</ie:webject>
<ie:webject name="Put-Blob-Stream" type="OBJ">
<ie:param name="INSTANCE" data="$(FORM[]instance[])"
default="jdbcAdapter"/>
<ie:param name="CLASS" data="BLOBTEST"/>
<ie:param name="ATTRIBUTE" data="FILECONTENT"/>
<ie:param name="WHERE"
data="(NAME='$(FORM[]filename[0])')"/>
<ie:param name="GROUP_OUT" data="TEMP"/>
</ie:webject>