Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Retrieve a file client resources
Retrieve a file client resources [message #1355088] Wed, 14 May 2014 15:14 Go to next message
marco giudici is currently offline marco giudiciFriend
Messages: 152
Registered: February 2013
Location: Italy
Senior Member
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 20:41 Go to previous messageGo to next message
Matthias Zimmermann is currently offline Matthias ZimmermannFriend
Messages: 83
Registered: February 2010
Member
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 09:06 Go to previous messageGo to next message
marco giudici is currently offline marco giudiciFriend
Messages: 152
Registered: February 2013
Location: Italy
Senior Member
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 14:37 Go to previous messageGo to next message
Matthias Zimmermann is currently offline Matthias ZimmermannFriend
Messages: 83
Registered: February 2010
Member
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 14:55 Go to previous message
marco giudici is currently offline marco giudiciFriend
Messages: 152
Registered: February 2013
Location: Italy
Senior Member
Thanks for the explanation and for your valuable suggestions
Previous Topic:Controlling if execChangedValue() is called or not.
Next Topic:Tree Box
Goto Forum:
  


Current Time: Sun Dec 21 11:28:06 GMT 2014

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

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