Hello Everybody
Servoy 6.0.3 Webclient
I show a velocity report in an html-aera on my form :
vhtml = plugins.VelocityReport.renderTemplate("PasProdukte.html", m_produktinfos(), resolution);
In my PasProdukte.html i have this to show some links and offer them to download
<tbody>
#foreach($record in $datasetd)
<tr>
<td><a href="javascript:m_dateiDownload('$record.PRODUKTDOKUMENT')">$record.PRODUKTDOKUMENT</a></td>
<td>$record.DOKUMENTTYP</td>
</tr>
#end
</tbody>
In my m_dateiDownload i do:
function m_dateiDownload(vdokument) {
var file = plugins.file.convertToJSFile(vdokument);
plugins.file.writeFile(file.getName(), file.getBytes());
}
In the html-aera the table with the records of datasetd are shown as expected:
\fileserver\dir\dir\filename.pdf
But in my method vdokument has:
fileserverdirdirfilename.pdf = missing backslashes ???
After hours of testing i found a workaround to get the needed string for the download method.
In my data collecting method i do something like this:
var pdquery = "select produktdoktyp.dokumenttyp,produktdokumente.produktdokument,NULL as dummy "+
" from produktdokumente join produktdoktyp on produktdoktyp.produktdoktypid = produktdokumente.produktdoktypid "+
"where produktstammid = '"+vproduktid+"'";
//the dummy column gets the manipulated string
var pddataset = databaseManager.getDataSetByQuery("maxdb",pdquery,null,-1);
for (var i = 1 ; i <= pddataset.getMaxRowIndex() ; i ++ )
{
var pdpfad = pddataset.getValue(i,2);
pdpfad = utils.stringIndexReplace(pdpfad,1,2,'\\\\vm-s-file1\\pb-allgem'); // changing mapped directory x: to fileservername\wantedDirectory
pddataset.setValue(i,2,pdpfad);
var vdummy = utils.stringReplace(pdpfad, '\\','//'); // putting the needed string for downloading into the column dummy
pddataset.setValue(i,3,vdummy);
}
context.datasetd = pddataset;
Finaly i had to change my PasProdukte.html
#foreach($record in $datasetd)
<tr>
<td><a href="javascript:m_dateiDownload('$record.DUMMY')">$record.PRODUKTDOKUMENT</a></td>
<td>$record.DOKUMENTTYP</td>
</tr>
#end
Strange !!!
Why does
$record.PRODUKTDOKUMENT return produktdokument without slashes to my m_dateiDownload method??Couldn’t this one be easier ??
Did i miss something??
Regards
Albert