1
Hello, I am with this doubt, I already managed to list the directories with methods found on the internet, but I could not implement in a method that feeds a <h:selectOneMenu>
to select an item. Any suggestions/solutions?
Thank you.
To list the directories:
private String selectItem;
private List<SelectItem> siglas;
@PostConstruct
public void init() {
this.modulo = new Modulo();
getAllModulos();
/* Listagem de diretórios para popular o SelectOneMenu */
siglas = new ArrayList<SelectItem>();
File directory = new File(".");
File[] subdirs = directory.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY);
for (File dir : subdirs) {
siglas.add(new SelectItem(dir.getName(), dir.getName().toUpperCase()));
} /* fim da listagem de diretórios */
}
Running this method on a main, it shows the structure of the application, but when running on Tomcat, it only shows the structure of the operating system.
Selectonemenu
<h:selectOneMenu id="siglas" value="#{moduloBean.modulo.sigla}" label="Siglas">
<f:selectItem itemLabel="Selecione..." noSelectionOption="true"/>
<f:selectItems value="#{moduloBean.siglas}"/>
</h:selectOneMenu>
Add your xhtml, service and Entity to the post, so we can help you better.
– LeoCBS
updated post. @Leocbs
– T. Tosin
Your selectOneMenu is inside a form?
– LeoCBS
yes, if I put the code the way it is there, it lists, but only the directories of the Operating system, and I would like to list the directories of the application, src,main,webapps, meta-inc, web-inf. understands?
– T. Tosin