Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » FileChooser and Accepted File Extensions
FileChooser and Accepted File Extensions [message #1857436] Tue, 07 February 2023 17:41 Go to next message
Chris Palmer is currently offline Chris PalmerFriend
Messages: 6
Registered: November 2022
Junior Member
Hi,

I have a problem with the FileChooser and would appreciate any advice.

It seems that only certain file extensions are allowed to be used. These are defined in the class UploadRequestHandler.DEFAULT_VALID_FILE_EXTENSIONS (org.eclipse.scout.rt.ui.html.json). However, I also need to work with files that have other than the defined extensions.

In the interface IUploadable.getAcceptedUploadFileExtensions() it is apparently also possible to enter file extensions.

Can anyone give me a hint as to where and how to intervene in order to also use other file extensions.

Many thanks
Re: FileChooser and Accepted File Extensions [message #1857446 is a reply to message #1857436] Wed, 08 February 2023 06:03 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
You can override the default implementation with your own implementation:

@Replace
public class OwnUploadRequestHandler extends UploadRequestHandler {

  @Override
  protected Set<String> getValidFileExtensionsDefault() {
    return Collections.singleton("zip");
  }
}


Above implementation would only allow "zip" files; from reading the code it should also be possible to return an empty set to allow any extension (even though might not be recommended).
Re: FileChooser and Accepted File Extensions [message #1857450 is a reply to message #1857446] Wed, 08 February 2023 11:21 Go to previous messageGo to next message
Chris Palmer is currently offline Chris PalmerFriend
Messages: 6
Registered: November 2022
Junior Member
it worked. thanks a lot Matthias!
Re: FileChooser and Accepted File Extensions [message #1857451 is a reply to message #1857450] Wed, 08 February 2023 11:44 Go to previous messageGo to next message
Chris Palmer is currently offline Chris PalmerFriend
Messages: 6
Registered: November 2022
Junior Member
I have a supplementary question: When I use getConfiguredFileExtensions, it seems that my specific file extensions are filtered out. I could not find where this is done. Where do I have to intervene for this?
Re: FileChooser and Accepted File Extensions [message #1857707 is a reply to message #1857451] Wed, 22 February 2023 03:59 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
When using

 @Override
 protected List<String> getConfiguredFileExtensions() {
  return Collections.singletonList("zip");
}


only ZIP files should be allowed (see OwnUploadRequestHandler above which might need to be adjusted too).
Re: FileChooser and Accepted File Extensions [message #1857714 is a reply to message #1857707] Wed, 22 February 2023 09:24 Go to previous messageGo to next message
Chris Palmer is currently offline Chris PalmerFriend
Messages: 6
Registered: November 2022
Junior Member
thanks but unfortunately that does not work. Having a file with an extension ".zzz" and using the getConfiguredFileExtensions as shown, is not showing the files with that extension.

It only works with the given extensions (UploadRequestHandler.DEFAULT_VALID_FILE_EXTENSIONS)
Re: FileChooser and Accepted File Extensions [message #1857715 is a reply to message #1857714] Wed, 22 February 2023 10:03 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
Did you adjust the method getConfiguredFileExtensions and add a custom UploadRequestHandler with the new file extension .zzz?

How do you try to upload the file? File chooser browser dialog? Is the file shown in the file chooser and just not uploaded? Or is it not even shown in the file chooser?
Re: FileChooser and Accepted File Extensions [message #1857716 is a reply to message #1857715] Wed, 22 February 2023 10:13 Go to previous message
Chris Palmer is currently offline Chris PalmerFriend
Messages: 6
Registered: November 2022
Junior Member
yes I did.

If I use getConfiguredFileExtensions with ".zzz" the file will not be shown in the file chooser.
If I use getConfiguredFileExtensions with null, all files, inlcuding the ones with extension ".zzz", will be shown and I can choose and upload a file with ".zzz" extension
Previous Topic:TablePage pagination
Next Topic:Cannot find the source of Javascript error
Goto Forum:
  


Current Time: Fri Jul 12 14:10:51 GMT 2024

Powered by FUDForum. Page generated in 0.04110 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top