JavaFX 2.0 :: How To Handle File Download In WebView
May 6, 2015I can't find an handler or a listener to intercept the 'Save as' window that should pops up when i click on a download link in a webview embedded page.
View RepliesI can't find an handler or a listener to intercept the 'Save as' window that should pops up when i click on a download link in a webview embedded page.
View RepliesI have a FileChooser:
JFrame parentFrame = new JFrame();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle(txtPushCode.getText());
int userSelection = fileChooser.showSaveDialog(parentFrame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
[Code] ....
But as you can see, it downloads only to "C:android empcoloricon.png". I want to download it to path where I chose in FileChooser with the name and extension I choose. In short, how can I use dynamic file path names in where ever I want in my applications?
I'm using WebView to display an OpenLayers3 map, e.g. Animation example from openlayers.org. When I lock my screen and unlock it, none of the openlayers layers are re-drawn. Sometimes bringing the window in to focus or a small resize of the component will cause the map to go blank. This doesn't occur in any browser I've tested, so it seems to be a WebView specific issue, although it also seems to be layer specific and possibly cache related. I've only tested on Windows, 1.7.0_51 x64 and 1.8.0_05 x64 ....
View Replies View RelatedI would like to reopen the following discussion: Show SVG-Image in WebView (JavaFX 8)
In our IDE (Eclipse Luna) running with jdk1.8.0_25 we load a html page into the webengine. The html page contains <img> tags with '.png' and '.svg' as src. Everything looks fine.
But if we execute the programm with java -jar, the WebEngine doesn't display the svg-files. Instead it shows the 'File not find'-Icon. The .png files still work
The files are definitly included into the jar and will be displayed if we link to them via <a href="someSvg.svg"></a>
So why it doesn't work.
I tried to print something using the new JavaFX 8 printing logic. Unfortunately, it does not work.
System:
Linux Mint 17x64
Oracle JDK 8u5
Default printer is cups pdf
Code:
package sample;
import javafx.fxml.FXML;
import javafx.print.PrinterJob;
import javafx.scene.control.TextField;
[Code].....
Debugging shows the array MediaPrintableArea[] mpa at J2DPrinter:839 is missing its first element, which causes the exception at line 844.
If I execute
service.getSupportedAttributeValues(MediaPrintableArea.class, null, null)
instead of
service.getSupportedAttributeValues(MediaPrintableArea.class, null, pras)
I get an array with an element on the first position.
The msn object used for the PrintRequestAttributeSet is "iso-a4", which causes the missing first element in the MediaPrintableArea[] array.
So why does this happen? Am I missing some important config stuff? I tried to fix it myself, but I am not able to debug service.getSupportedAttributeValues(...).
I'm building app using Javafx Webview, but I have problems with running any Youtube video in Webview. The strange thing is that rarely it plays ok but more often it shows info "An error occurred, please try again later".
I tried to figure it out, so I made simple app using Youtube iframe API and firebug lite to show where is the problem:
Here is source of Main.java
Here is source of video.html
When I run it on my PC I see the result as below:
Error state 5 means "The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.".
When I run this video.html file in firefox, chrome, or internal eclipse browser, everything is ok and always work.
I use JRE and JDK 1.8.20 but tried also with older versions, Windows 7 64 bit. I've also installed DivX - did not work. I tried on different PC (also win7 64 bit) and asked 2 people with similar config to run this - and it is not working. As far as I know there is everything ok on Mac.
I've run in an issue with connection timeout in the WebView. Requesting the URL in a browser will result in an answer, however it may take some time. Running the same request from the WebView results in a connection timeout.
What is the connection timeout for loading a page through the WebView (from issuing the request webEngine.load(url) to the state change failed passes about 40s). The Request in a browser takes about 10s.
Can I manipulate the underlying connection of the WebView (as suggested at java - How to connect to an HTTPS URL from a JavaFX application - Stack Overflow)
Can I set the connection timeout on the WebEngine/WebKit or per request?Is there an issue targeting this?Likewise I would be interested to get a handle on the connection so I can evaluate the header data to retrieve useful information (like response was a PDF which cannot be rendered in the WebView)....
I have a WebView which displays a site. At a specific page I want to fill in some values into <input> elements. So i use such an event handler (browser is of WebView class)
browser.addEventHandler(MouseEvent.MOUSE_CLICKED,
new EventHandler<MouseEvent>(){
public void handle(MouseEvent e) {
Document doc = webEngine.getDocument();
if (doc == null) {
System.out.println("Doc is null");
[Code] ....
The handler sets the "value" but view doesn't reflect that, field is empty.
I am trying to develop a app for facebook and other social networks using webview. When the app is closed all the cookies are removed and when it is relaunched we can't get use of cookies. I want to know how to store cookies permanently and use them when the browser is relaunched. And I also want to know how to save web history permanently.
View Replies View RelatedI have a big issue to render this html page with the webview component :
<html><head lang="en"> <meta charset="UTF-8"> <title>Pb Rotate</title> <style type="text/css"> #myDivRotate {
color: purple; background-color: #d8da3d; height: 200px; width: 300px; margin-top: 20px; margin-left:20px; -webkit-transform:perspective(400px) rotateX(30deg); -webkit-backface-visibility: visible; }
</style></head><body> <div id="myDivRotate"> Coucou
</div></body></html>
The problem is from "perspective" in -webkit-transform. Without it's ok. But with this one, the result is different from a standard browser like chrome or safari.
I have a WebView and a Javascript that appends an <img> tag in a webview.
Like so:
function insertImg(src) {
$("body").append("<img src='" + src + "'/>");
}
I call this function with the following code:
String path = "file://Users/rod/Desktop/123.gif";
webengine.executeScript("insertImg('" + path + "')");
However, this does not work and no image is displayed.
How can this be achieved?
I want to ask if there is an option to set the vertical position of the node handles of the TreeView-control.
I used a custom TreeCell factory with icons of sizes between 24 and 64 pixel and the location of the handle is regardless of the size of the icon on top of the cell. So if you got large icons the view did not look so nice.What I want is a property or something to center the handle in the cell depending on the size of the cell. Is there such an option?
How to catch the event when table view's column are re-positioned. Basically when the column is re-positioned from 1 position to 5 position , i want to do update the db.
View Replies View RelatedI am trying to display the files stored in server using jsp. I used the code below to display. But for pdf it is asking to download (No option for open). For XLS, XLSX, DOCX, PPT and PPTX it is showing zip file to download. For type doc it is showing junk data.
<%
String fileName=(String)request.getAttribute("fileName");
int loc = fileName.lastIndexOf(".");
String fileName1 = fileName.substring(0, loc);
String fileName2 = fileName.substring(loc + 1, fileName.length());
[Code] ...
String contentType = fi.getContentType(); gives text/plain when my file is.txt file and gives image/jpeg when my file is .jpeg file but when my file is .jar or .docx it will return application/octet-stream and application/vnd.openxmlformats-officedocument.wordprocessingml.document respictively so what to do to get exact mime type.
View Replies View RelatedProblem in download xml file from physical location. After download show current jsf page in xml file !!!
public void downloadFile() {
File file = new File("c:/home/marco/file.xml");
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
response.setHeader("Content-Disposition", "attachment;filename=file.xml");
response.setContentLength((int) file.length());
ServletOutputStream out = null;
[Code] .....
I currently have the following code that I use to download a file from a website:
URL website = new URL(imgurl);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(dir+""+imageNumber + "." + extension);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
Usually, the code works very well. But sometimes, the download gets stalled indefinitely. Is there a way to set a time out period for the downloading of this file?
Is there a way to measure current download speed of a file being downloaded? I've searched all over google and the only thing i get is average download speed. This is basically how it is being done, the result is average download speed.
Java Code:
OutputStream out = null;
URLConnection conn;
InputStream in = null;
long startup = System.currentTimeMillis();
try {
URL url = new URL(adress);
out = new BufferedOutputStream(
[Code] .....
I have uploaded file into specified folder.So I have to download it..
View Replies View RelatedI have also tried above code with few changes but I got error. Code and error show below.
Java Code:
package practice;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
[Code] .....
Error:
Java Code:
Jun 16, 2014 6:21:33 PM practice.TestFTPProgram main
SEVERE: null
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
[Code] .....
I have a class that do a soap request to a web service , the response is containing a base64 string repressing a file content , how can i send this string to a servlet (maybe any other way) to send it to the user as a downloaded file .
View Replies View RelatedI need to get the html in string when i hit the hit the jsp in servlets basically i need to put the output of jsp in pdf file when i hit one link i need to download that data in pdf file. I am using itextpdf.
Sample code
pResponse.setContentType("application/pdf");
((HttpServletResponse) pResponse).setHeader("Content-Disposition", "attachment; filename=report.pdf");
//Get the output stream for writing PDF object
OutputStream outStream=pResponse.getOutputStream();
ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
[Code] ....
I need to convert the sample download.jsp to html so that i can parse
// XMLWorkerHelper.getInstance().parseXHtml(docWriter, document,new FileInputStream(jspPath),new FileInputStream(csspath) ,null ,new XMLWorkerFontProvider());
This issue is regarding response from the servlet
I have written a code to download .csv file with records from DB.
To download records i am uploading a .CSV file containing telephone number.
After downloading the .CSV file page is not getting refreshed.
Below is the code snippet i am using,where i am setting response content type as test/csv.
ServletOutputStream op = resp.getOutputStream();
// Set content type of output
resp.setContentType("text/csv");
resp.setHeader("Content-Disposition", "attachment; filename="test"");
op.flush();
op.close();
How that page will get refreshed after csv file download or after response.
Recently we got an issue about file download. We are using below code to fetch the data from backend(DB2) and export to excel.
Before Jan 15 it use to take 2 minutes to download the file (2 MB size). But now its taking half an hour to download.
response.setContentType("application/vnd.ms-excel");
response.setHeader("content-disposition","attachment; filename=Attendance_Report.xls");
We have restarted server, system but still problem exists. We found that there is no code level or data base level or network level issues.
Now we have to see server level issue. What are the factors which effects the file downloading at server level.
We are using websphere 6.1 ,java1.4
I am writing a code that I want only to accept numbers 1 through 8 and to recognize when it isn't an integer being put in. I tried the following:
Java Code: int classSelect = keyboard.nextInt();
try
{
while( (classSelect<1 || classSelect>8))
[Code]....
In my EJB modules, to prevent that any JPA exception is ever thrown, I check the condition that would cause the exception beforehand. For example, the exception javax.persistence.EntityExistsException is never thrown because, before persisting the entity, I check if such primary key already exists in the DB. Is it the right way to do this?
Another approach is too allow the JPA exceptions to be thrown and catch them in a try-catch block, and then throw my custom exception from the "catch" block. However it requires to call EntityManager.flush () at the end of the "try" block. Otherwise the exception throw could be deferred and never be caught by my block.