When i’m using the function application.getServerUrl in a web client, servoy gives me localhost:8099 (my servoyport) and not the real name of my server.
Is it a bug or must i change something in my configuration?
Servoy 357
When i’m using the function application.getServerUrl in a web client, servoy gives me localhost:8099 (my servoyport) and not the real name of my server.
Is it a bug or must i change something in my configuration?
Servoy 357
A web client is running ON the server, so that’s why it returns localhost. To get the actual ip of the server, you can do something like this:```
plugins.http.getPageData(“IP Address API”);
I generate temp pdf file report with jasper in the servoyroot/web-client/tempdirectory and then i do a showurl of the temppddfile.
I think so that i must put the server url in a global var of my application.
With the latest version of the JasperReports plugin, you can just use the “view” option in the WC and a PDF will be automatically generated and pushed to the WC.
Paul
Paul, can you tell which ireport version is still 100% compatible with the jasper report plugin?
The JasperReports plugin is compatible with all versions of JasperReports.
You just have to make sure that the JasperReports libraries that the JasperReports plugin uses are the same or a higher version than the ones iReports uses.
The latest version of the plugin (2.1.1) can be downloaded as a complete package with all the libraries of JasperReports version 3.0, which iReports 3.0 also uses.
Paul
oke thanks!
Thanks Paul for this feature
It Works like a charme in the webclient.
Servoy 4.1.1, FireFox, WinXP
I have a related question.
My solution generates pdfs and stores them in the database. In the smart client, when I want to display the pdf I am saving it to a temp file (tempFile) and then using this code I found in one of Bob Cusick’s demos to display the PDF in Acrobat Reader:
if(utils.stringMiddle(application.getOSName(),1,7) == "Windows")
{
application.executeProgram('rundll32', 'url.dll,FileProtocolHandler',tempFile)
}
else if(utils.stringMiddle(application.getOSName(),1,7) == "FreeBSD"||utils.stringMiddle(application.getOSName(),1,5) == "Linux")
{
application.executeProgram('mozilla', tempFile)
}
else if(utils.stringMiddle(application.getOSName(),1,6) == "Mac OS")
{
application.executeProgram('open', tempFile)
}
But this isn’t working in the web client. In the Web Client, this causes the PDF to open on the server!
What’s the correct procedure to display a db-stored pdf file in the web client? I don’t care whether it’s in the browser or in its own Acrobat window.
I’ve tried this, thinking at least this would work in Developer, if not on the server, but it doesn’t work.
function btnShowPDF()
{
var tempFile = plugins.file.createTempFile('SmartTrash','.pdf') //creates empty temporary file
application.writeFile(tempFile,hauls_to_haul_po_pdfs.pdf) // writes the media field to file
tempFile = utils.stringReplace(tempFile,'\\','\/')
application.showURL('file:///'+tempFile,'_blank')
}
}
I’ve also read Westy’s advice here: http://www.servoy.com/forum/viewtopic.p … 8&start=15 but that seems to be for a deployed solution - what about just getting it to work in Developer for starters?
Please help! Thank you.
Dean’s answer http://www.servoy.com/forum/viewtopic.p … 8&start=15 IS the way you do it. Even in developer. Remember, when you’re in developer, you ARE deployed and the Tomcat web server is running (that’s how you get a web client in the first place).
Use Dean’s method and it should work just fine.
Dean’s answer IS the way you do it. Even in developer. Remember, when you’re in developer, you ARE deployed and the Tomcat web server is running (that’s how you get a web client in the first place).
OK I figured it out. Dean’s method does not work in developer, and that’s because when he does this:
var installdir = java.lang.System.getProperty("user.dir")
under developer this returns ‘C:\Servoy\developer’. In order to work, it needs to return ‘C:\Servoy\application_server’
So in order to have a single method that works in both server and developer I guess I could test if the word ‘developer’ appears in installdir and if so replace it with ‘application_server’ … not very elegant but it works … got any other ideas?
Here’s what Dean’s method looks like now:
if (application.getApplicationType() == 5) // web client
{
var installdir = java.lang.System.getProperty("user.dir")
// to make it work in Developer we need to redirect this path to the application_server folder
installdir = utils.stringReplace(installdir,'developer','application_server')
installdir = utils.stringReplace(installdir,'\\','\/');//original code edited to include this line
var uuid =application.getNewUUID();
var filename = uuid+'.pdf';
var filepath = installdir+'/server/webapps/ROOT/'+filename;
var success = plugins.file.writeFile(filepath,hauls_to_haul_po_pdfs.pdf);
application.output('filepath=' + filepath +' filename='+filename)
if (success)
{
application.showURL('/'+filename,'_blank')
}
}