Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » Retrieve a file client resources
Retrieve a file client resources [message #1355088] Wed, 14 May 2014 11:14 Go to next message
Eclipse UserFriend
Hi all,
I have the following question/need:

I would need to specify in my code the location of a file in resorces of my package "client" (as you can see in the picture below)

index.php/fa/18090/0/

This file is a Excel file that I use as template to generate a report in Excel with jXLS library. The used code is the following:

        Map beans = new HashMap();
        beans.put("list", list);

        XLSTransformer transformer = new XLSTransformer();
        transformer.transformXLS(templateFileName, beans, destFileName);


The user can define the destination using a filechooser [destFileName]; instead the template is always the same and I thinked to put this into the resources folder of the client package, but I cannot retrieve it.

Is this possible? How?

Thanks in advance for any suggestion
Re: Retrieve a file client resources [message #1355648 is a reply to message #1355088] Wed, 14 May 2014 16:41 Go to previous messageGo to next message
Eclipse UserFriend
Let's assume that you save your Excel template file in the client plugin under resources/templates/MyTemplate.xlsx
You should then be able to retrieve the content of this with the following snippet:

  URL url = Activator.getDefault().getBundle().getResource("/resources/templates/MyTemplate.xlsx");
  byte [] content = IOUtility.getContent(url.openStream()));


hope this helps
Re: Retrieve a file client resources [message #1356884 is a reply to message #1355648] Thu, 15 May 2014 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi Matthias,
I have a doubt regarding the first part of your suggestion.
I don't understand exactly what you mean with

Quote:
Let's assume that you save your Excel template file in the client plugin under resources/templates/MyTemplate.xlsx


Please, can you explain me better?

Thanks in advance for your explanation
Re: Retrieve a file client resources [message #1357468 is a reply to message #1356884] Thu, 15 May 2014 10:37 Go to previous messageGo to next message
Eclipse UserFriend
In your first screenshot there ist the resources folder (highlighted in yellow). i was suggesting that you could create a subfolder named 'templates' there which in turn would then hold all the template files that you need in your application.

The drawback of your approach is that you will need to update your application and redeploy in case a template needs to be changed. A more flexible solution would store template files in a database and provide the administrator of the application with the means to change/add/delete such templates.
Re: Retrieve a file client resources [message #1357497 is a reply to message #1357468] Thu, 15 May 2014 10:55 Go to previous message
Eclipse UserFriend
Thanks for the explanation and for your valuable suggestions
Previous Topic:application configuration management
Next Topic:Tree Box
Goto Forum:
  


Current Time: Wed Jul 23 16:43:08 EDT 2025

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

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

Back to the top