Access images from resources directory in Maven Facelets project
-
11-11-2019 - |
Question
Firstly, please forgive me if I have asked this before (i suffer memory problems due to a brain tumor.)
I am trying to roll a Managed Bean to fetch images from a directory, but don't know how to get the url for iether of the following locations:
1)Maven 'resources' dir & 2)webapp/images dir (from withing my Managed bean.
Additionally is it still fine to use h:datatTable
to display data as I understand Tables to be somewhat outdated no?
I have written a large portion of the desired bean and am just seeking info on how (if possible) to find the urls or set the url as a managed property.
package com.buhaugane.util;
/**
* Created by IntelliJ IDEA.
* User: Yucca http://thejarbar.org
* Date: 2/23/12
* Time: 10:21 AM
* To change this template use File | Settings | File Templates.
*/
import org.apache.commons.collections.ArrayStack;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import java.io.File;
import java.util.Arrays;
import java.util.List;
/**
* Contain utility methods to interact with images.
*/
@ManagedBean(name = "images")
public class ImageBean {
List<File> images;
static String thumbUrl;
static String fullSizeURL;
/**
* Returns all thumbnails at specified url
*/
public static List<File> thumbnails (){
thumbUrl=//can I get it from context if I can't set url as a manages property?
File[] files = new File(thumbUrl).listFiles();
List<File> returnList = Arrays.asList(files);
return returnList;
}
/**
* Returns all full-sized images at specified url
*/
public static List<File> fullSized (){
thumbUrl=**//can I get it from context if I can't set url as a manages property?**
File[] files = new File(thumbUrl).listFiles();
List<File> returnList = Arrays.asList(files);
return returnList;
}
}
Many thanks, Yucca
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow