application.showurl is not working in web client

Forum to discuss the Web client version of Servoy.

application.showurl is not working in web client

Postby nestrocuation » Fri Jul 30, 2010 9:01 pm

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 .
nestrocuation
 
Posts: 61
Joined: Tue Jun 08, 2010 11:27 pm

Re: application.showurl is not working in web client

Postby sbutler » Sat Jul 31, 2010 5:02 am

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.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: application.showurl is not working in web client

Postby jcompagner » Mon Aug 02, 2010 10:11 am

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:

Code: Select all
plugins.file.writeFile("release.pdf",foundset.releasedpdf);


So dont make a tempfile just give the name and call write file.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: application.showurl is not working in web client

Postby nestrocuation » Tue Aug 03, 2010 5:17 pm

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 .
nestrocuation
 
Posts: 61
Joined: Tue Jun 08, 2010 11:27 pm

Re: application.showurl is not working in web client

Postby jcompagner » Tue Aug 03, 2010 5:58 pm

do not create file objects those dont make any sense in the webclient
just do 1 single statement as i described above:

Code: Select all
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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: application.showurl is not working in web client

Postby nestrocuation » Tue Aug 03, 2010 7:38 pm

Hey ,

Thanks a Lot I totally Understand What was going on .It worked out just perfect .

:idea:
nestrocuation
 
Posts: 61
Joined: Tue Jun 08, 2010 11:27 pm


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 21 guests

cron