Combo Box Filler via SelectItems (Java)


	@SuppressWarnings("null")
	//begin comboList Items grab
	public List<SelectItem> getSelectItems() throws IOException {

		//set up empty placeholder list Items
		List<SelectItem> selectItems = new ArrayList<SelectItem>();

		//Directory where files reside
		File localDir = new File("C:\\temp\\WEB_FILES");
		
		//local variable statement
		FilenameFilter filterDir = new FilenameFilter() {
			public boolean accept(File localDir, String fileName) {
				return fileName.startsWith("JFreeChartCSVData");
			}
		};
		//plug matching files into String array
		String[] localFiles = localDir.list(filterDir);
		//ensure directory actually contains fileNames startsWith("JFreeChartCSVData")
		if (localFiles == null) {
			System.out
					.println("Files not found, please check directory listings");
		//loop through directory if it actually contains fileNames startsWith("JFreeChartCSVData")
		} else {

			//enter loop, grab all matching files
			for (int i = 0; i < localFiles.length; i++) {
				//load matching files to comboBox variable
				String cboFiles = localFiles[i];

				//set up files into selection comboList
				selectItems.add(new SelectItem(localDir + "\\" + cboFiles.toString()));
			}
		}		
		//...
		//List localFiles found
		return selectItems;
	}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...