-
1. Re: Solder / getWebResource to all files in a folder - How?
lightguard Aug 9, 2012 12:36 PM (in response to aykay)We never had that use case come up when we designed the feature. As far as I know, there isn't a way to do this with Solder.
-
2. Re: Solder / getWebResource to all files in a folder - How?
aykay Aug 9, 2012 12:42 PM (in response to lightguard)Thanks!
In fact I programmed a solution meanwhile which I'll post a soon as I can spare some time.
Cheers, and keep up the great stuff you're doing.
-
3. Re: Solder / getWebResource to all files in a folder - How?
davisonri_k12 Aug 12, 2012 2:15 AM (in response to aykay)Great. I was looking to do something similar to load up multiple seam-beans.xml files (broken down into smaller more meaningful parts from the big seam-beans.xml that I initially had). it would be great if you can post your solution. Thanks
-
4. Re: Solder / getWebResource to all files in a folder - How?
aykay Sep 6, 2012 3:03 PM (in response to davisonri_k12)Hi Dave.
Terribly sorry about my late respone.
In the mean time project demands had altered in a way that my solution simply doesn't fit the original question anymore. When mentioning it I wasn't aware of this. Now I could spare some time to figure out how I'd solve my original request. Please bear with me that I again sticked to using java.io.File to get hold of all file names residing in a parcticular web folder. In order to input stream and process all of them I did:
import javax.faces.context.FacesContext; import javax.servlet.ServletContext; ... public void processAllResources(String folderInWebContext) throws IOException { ServletContext servletContext = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext(); if (folderInWebContext.charAt(0) != '/') // Add global web root folderInWebContext = "/" + folderInWebContext; File webRootFolder = new File(servletContext.getRealPath(folderInWebContext)); File[] files = webRootFolder.listFiles(); if (files != null) for (File file : files) { String fileName = file.getName(); String resourceTerm = folderInWebContext + "/" + fileName; WebResourceLocator locator = new WebResourceLocator(); InputStream inputStream = locator.getWebResource(resourceTerm); // Process this input stream // ... inputStream.close(); } }
As always, code can surely be improved and I welcome hints. Of course, I tested it successfully.
Cheers
AyKay