Open Hugolarson opened 4 years ago
Feel free to ask a question on StackOverflow and just add a ticket here to make sure we will get notified. After some time we might get our JPro-Tag :-)
Hi, Regarding filechooser sample. All I could find was a way to drop a file to area to be uploaded. What is needed in my opinion is a full fledged file file/directory browser/selector that is non modal for opening and saving files.
It's not allowed to select your files in a different way by the browser client. The sample also shows how to open the file browser (clicking on the area) and downloading files to the client. Or do you want to select a file in the server? In this case, it would be required to write a new file chooser in pure JavaFX - which would be nontrivial. But usually, you don't want to give access to the server to the client.
Hi,
No I want to select file on client side. I missed that clicking opens the filehandler but its modal and block other input. Is this okej with Jpro? Does this not block UI thread?
Thanks,
Yes, that's ok with JPro. The application doesn't really know how the browser implemented the file upload. It doesn't block the UI-thread in the server, and I think it also doesn't block the thread in the browser.
Hello, What about a Directory Chooser?
Browser don't allow you to select directories in general. For that reason, JPro also can not support it. https://stackoverflow.com/questions/2809688/directory-chooser-in-html-page
Found this promising project https://github.com/Oliver-Loeffler/FXFileChooser But alas it's not possible to open the chooser in non modal manner.
Solving this issue maybe FXFileChooser can be used with JPro https://github.com/Oliver-Loeffler/FXFileChooser/issues/36
It would be possible to use this (if it's not blocking the fx-thread) but be aware, that it would allow your User to choose files in the server and not in the client. This is usually something which is not wanted.
Of course the files shown will be on the server. Thanks for reminding me. This is not what I want. Now I think I know what I need. I want to save a a named file on the client. It's possible to do it in the browser. Is it possible to do it with JPRo file handler? Setting a file name and when Save button is pressed in a selected folder the file will be saved there with the given name. If user select another file it will be replaced.
You can only use the "download-feature" of the browser. You can define the filename of the downloaded file. If you download a file with the same name, then usually " (2)" gets added to the filename. You also cannot select the file/folder where the file get's downloaded.
I guess what is needed is a WebApi.FileDownloader in addition to existing WebApi.FileUploader.
Thanks,
For downloads, a possible approach could be to se the Notifications from ControlsFX. A notification can contain all sorts of controls such as hyperlinks and images. So a custom notification, with a download icon and a hyperlink would probably trigger the browser download function.
For file and directory browsing, it has become a security standard that web applications are not permitted to walk through client directories.
Well, I have zero experience yet with JPro. In HTML, when running the following code, one will get 2 buttons. A file select and a submit button.
<!DOCTYPE html>
<html>
<body>
<p>Renders 2 buttons - one for file select, one for submit.</p>
<form>
<input type="file" id="myFile" name="filename">
<input type="submit">
</form>
</body>
</html>
Would it be possible to create a file chooser for JPro which act in following way:
Regards, Oliver
@Hugolarson
For downloading you can just use this method: WebAPI.downloadURL()
@Oliver-Loeffler That can already be implementable with WebAPI.fileUploaderNode()
Tried and half expected that the browsers save file dialog to show. Instead it downloaded the file to browser default save directory. getWebAPI().downloadURL(new java.io.File("c:/1/test.pdf").toURI().toURL());
@Hugolarson I don't think save dialogs are possible in the browser. If you can show us a proper save-dialog then we will add something similar to JPro. Then it's probably also possible to implement it yourself with the WebAPI.
Hi, Look at this image from Chrome with a nice save dialog with proposed file name. It would be great if you implement it. This technology (JPro) is very nice for us people of who Html5 and Javascript are mysteries.
This is the file chooser provided by the pdf-viewer integrated into chrome. I would need something which is provided by a normal webpage.
Sorry I have little knowledge in Html and JS. How about if one can propose a file name in the WebApi.filhandler dialog, just like in the image? When user press "open" in a folder without selecting a file name the WebApi.filhandler setOnFileSelected event gives the full path to the proposed file. And if user selects an actual file then that file full path is forwarded to the event.
Updated. But of course how to save the file to a local folder even if the path is known on the server side. No can do i think.
It would most likely be possible to provide a file-type to the fileuploader. setOnFileSelected won't be able to give you the path of the file, because the browser hides the real path for security reasons. I would recommend not trying to do more as other bebsites do, because it's usually forbidden by the browser and a waste of time.
Hello,
This is maybe not the place to ask questions but there is no "JPRO" tag in stackoverflow.
JavaFX FileChooser is modal which is "NO NO" in JPro. Any other way to brows local files?
A clever "JPro "way to view PDF files.
Is there a way to set a Session with event to log out a user and clean up resources after a set time?
Thanks,