Dynamically display catalogue images to web-page

UI Components for JSF
Post Reply
L576595
Posts: 1
Joined: 14 Aug 2018, 13:31

14 Aug 2018, 14:24

I am using JSF, Primefaces. I have a class that reads in from a list the location of images I want to display on a web-page so that "Customers" (This is a project for college) can view structures the "company" has for sale.

Code: Select all

 import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;
    
    public class ReadInLinks {
    
    	static List<String> sumoLinks = new ArrayList<String>();
    	static List<String> slideLinks = new ArrayList<String>();
    	static List<String> castleLinks = new ArrayList<String>();
    	static List<String> obstacleLinks = new ArrayList<String>();
    
    	static void readInSumo() throws FileNotFoundException {
    		File readFile = new File("./WebContent/images/SumoLinks.txt");
    		Scanner sc = new Scanner(readFile);
    		while (sc.hasNextLine()) {
    			sumoLinks.add(sc.nextLine());
    		}
    	}
    
    	static void readInSlide() throws FileNotFoundException {
    		File readFile = new File("./WebContent/images/SlidesLinks.txt");
    		Scanner sc = new Scanner(readFile);
    		while (sc.hasNextLine()) {
    			slideLinks.add(sc.nextLine());
    		}
    	}
    
    	static void readInCastle() throws FileNotFoundException {
    		File readFile = new File("./WebContent/images/BounceCastleLinks.txt");
    		Scanner sc = new Scanner(readFile);
    		while (sc.hasNextLine()) {
    			castleLinks.add(sc.nextLine());
    		}
    	}
    
    	static void readInObstacle() throws FileNotFoundException {
    		File readFile = new File("./WebContent/images/ObstacleLinks.txt");
    		Scanner sc = new Scanner(readFile);
    		while (sc.hasNextLine()) {
    			obstacleLinks.add(sc.nextLine());
    		}
    	}
    }
So each different page will access different structure types. Each array comes out looking kind of like this: [/BounceCastles/BigBounce.jpg, /BounceCastles/BounceAround.jpg, /BounceCastles/FrozenBounce.jpg, /BounceCastles/PartyBounce.jpg, /BounceCastles/SpiderBounce.jpg, /BounceCastles/UnicornBounce.jpg]

I am looking to display that images that array list points to so that if we decide to add more images later we won't need to hard code them in the "Client" can simply add the image to the file and then a link that points to it. All the examples I have found are for collecting blobs from database but for this project we don't have a DB we just have a folder with the images in them.

I am so confused.

Any help will be awesome.

Kind regards

Matthew

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests