List directory names, from a given location, in a selectOneMenu

1

Hello, I have this doubt, I have already been able to list the directories with methods found on the internet, but I have not been able to implement in a method that feeds a <h:selectOneMenu> so that an item is selected. Any suggestions / solutions? Thank you.

To list 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 I run 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>
    
asked by anonymous 11.03.2015 / 02:21

0 answers