<Web service URL>/InsertPrxPicture?mon=<report sheet moniker>
The InsertPrxPicture operation is used to insert an image to regular report sheet using POST request.
Operation parameters contain a moniker of regular report sheet, to which an image is to be inserted. The moniker is specified in the following format: <moniker of opened regular report>!<sheet key>. The report should be opened for edit. The loaded image should be included in the POST request.
The operation results in the identifier of the object created on the sheet. To save changes in regular report, use the SaveObject and SaveObjectAs operations.
Below is the example of code of the HTML page used for loading an image to regular report sheet. A form implemented on the HTML page is sent as a value. This form has a control that opens an image file. The image is sent on clicking the hyperlink. To save changes, use the additional function that is executed on clicking the second hyperlink.
To reduce the example, the PostRequest function script is excluded from the code, the function is used to execute operations in JSON format. See code of this function in the Connecting to Repository article.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Use of the LoadTopobase operation</title>
</head>
<body>
<script type="text/javascript">
var svc = "http://localhost:9090/axis2/services/PP.SOM.Som";
var prxId = "REG_REPORT";
var OpenPrxResult;
function getFormElement(id) {
var res = document.getElementById(id);
return res;
}
function sendForm(form, url) {
var sta = getFormElement('status');
sta.innerHTML = '';
var xhr = new XMLHttpRequest();
xhr.open('POST', url, false);
var data = new FormData(form);
xhr.send(data);
if (xhr.status == 200) {
sta.innerHTML = "Response:<p>" + xhr.responseText + "<p>";
} else {
sta.innerHTML = "Request execution error:<p>" + xhr.responseText + "<p>";
}
}
// Connect to repository and send request to execute the LoadTopobase operation
function LoadTopobase(form) {
//Repository connection
var OpenMetabase = { "OpenMetabase": { "tDef": { "id": "Warehouse" }, "tCreds": { "user": { "id": "User" }, "pass": "Password" } } };
OpenMetabaseResult = PostRequest(svc, OpenMetabase);
// Open regular report for edit
var OpenPrx = { "OpenPrx" : { "tObject" : { "id" : OpenMetabaseResult.OpenMetabaseResult.id + "!" + prxId }, "tArg" : { "args" : { "openForEdit" : "true" } } } };
var OpenPrxResult = PostRequest(svc, OpenPrx);
// Send image to server to insert to regular report
return sendForm(form, svc + "/InsertPrxPicture?mon=" + OpenPrxResult.OpenPrxResult.id.id + "!1");
}
function DoSave()
{
// Save regular report
var SaveObject = { "SaveObject" : { "tObject" : { "id" : OpenPrxResult.OpenPrxResult.id.id } } };
var SaveObjectResult = PostRequest(svc, SaveObject);
}
/*
PostRequest script
*/
</script>
<!--A form, which data is sent to server-->
<form id="fileForm" action="" method="" enctype="multipart/form-data" onsubmit="LoadTopobase(this)">
<div>
<input type="file" name="file" id="file" />
</div>
</form>
<!--Hyperlink for sending data-->
<div>
<a href="javascript:InsertPicture(getFormElement('fileForm'))">Insert Picture</a>
<a href="javascript:DoSave()">Save Report</a>
</div>
<!--A field for creating operation execution state-->
<div id="status"></div>
</body>
</html>
See also: