Hello All ,
The Code runs great on smart client but when i run it on web client it does not go the Url .
application.output(foundset.releasedpdf);
var file = plugins.file.createTempFile(revisions_to_documents.file_name.split(‘.’)[1],‘.pdf’);
plugins.file.writeFile(file,foundset.releasedpdf);
var url = new Packages.java.io.File(file.getAbsolutePath()).toURL(); // use java File to get URL
application.showURL(url);
I thought It was becuase of File plugin and i tried to use application.usr(‘http://www.google.com’);
and it did not worked out .Is there something specific that i need to do for running it in web client .
Thats really not the appropriate usage of the file plugin. You have to keep in mind with the WebClient, all of your code runs server side. so the URL to the file on the server (which is where your PDF is) isn’t accessible to the WebClient. You need to do some extra work to stream it to the client. We have a video on the usage of the File plugin in ServoyU if you are interested.
There are also some brand new functions added to the File plugin in version 5.2. The one that may interest you is streamFilesFromServer. If your not running 5.2, there are some other tricks to stream files to the webclient.
streamForm/ToServer is more for smart client (yes it will also work in the web but “streaming” doesnt make to much sense there because you stream in the same java machine on the server)
But in 5.1 you can just do this:
plugins.file.writeFile("release.pdf",foundset.releasedpdf);
So dont make a tempfile just give the name and call write file.
Hello ,
Thanks you very much for replying .This is change in code from what i understood .
var file = plugins.file.createFile(‘released.pdf’)
application.output(file.canWrite())
if(!file.canWrite())
{
file.createNewFile();
}
var rslt=plugins.file.writeFile(file,foundset.documents_to_revisions.rev_doc);
url = new Packages.java.io.File(file.getAbsolutePath()).toURL(); // use java File to get URL
application.showURL(“http://www.google.com”)
The Code Works fine on smart client but still am not able to make it work on web client .It stops at plugin.file.writefile and i also have upgraded my servoy version to 5.2 if it does matter.
Moreover my main aim is that user just needs to view the pdf file .Would appreciate a better way if possible , that i could write a bytes to a file and open up a pdf file .
do not create file objects those dont make any sense in the webclient
just do 1 single statement as i described above:
plugins.file.writeFile("release.pdf",foundset.releasedpdf);
and that foundset.releasedpdf are the bytes of your pdf. then you are done, this also works n 5.1
Hey ,
Thanks a Lot I totally Understand What was going on .It worked out just perfect .
![Idea :idea:]()