i trying create little "media library" fun on own , im struggling first simple task creating simple gallery.
i using primefaces on apache tomcat server. in /wptwebapps
folder have project , "file structure":
├───files │ └───root │ └───usr1 │ └───media │ ├───music │ ├───pictures │ └───video
what trying do, is, dynamically possible, read each picture in /pictures
, display them using primefaces galleria.
galleria on bilder.xhtml
<p:galleria value="#{galleriaview.images}" var="image" panelwidth="500" panelheight="313" showcaption="true"> <p:graphicimage name="../files/root/usr1/media/pictures/#{image}" alt="image description #{image}" title="#{image}" /> </p:galleria>
galleriaview.java
package com.deegee.media.gallery; import java.util.arraylist; import java.util.list; import javax.annotation.postconstruct; import javax.faces.bean.managedbean; import javax.faces.context.facescontext; @managedbean(name = "galleriaview") public class galleriaview { private list<string> images; private list<string> dir; @postconstruct public void init() { images = new arraylist<string>(); (int = 1; <= 12; i++) { images.add("usr1_" + + ".jpg"); dir.add(facescontext.getcurrentinstance().getexternalcontext().getrealpath("../files/root/usr1/media/pictures/") + images.get(i)); } } public list<string> getimages() { return images; } public list<string> getdir() { return dir; } }
the problem lies reading pictures file structure. extremely lazy im trying find easiest, simple solution (pathetic, know), i.e. want prevent using database or fancy ftp calls or stuff that.
so, can here? how can read file structure? or have resort databases etc.?
Comments
Post a Comment