是否可以从命令按钮调用此文件

时间:2013-02-04 10:57:27

标签: java jsf primefaces

我在调用java文件时遇到了一些问题,我创建了一个java文件

   @ManagedBean(name="pdfSearch")

public class pdfSearch {

    public String NewDestination;

    public void main(String[] args) throws IOException {

        File dir = new File(NewDestination);
        String[] extensions = new String[]{"pdf"};// Add more file formats here to disply, could use this later on to display to the user all the files they have uploaded
        System.out.println("Getting all .pdf files");
        List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
        for (File file : files) {
            System.out.println(file.getCanonicalPath());
        }

    }
}

但是我无法通过命令按钮来调用它

                <p:commandButton action="#{pdfSearch.main}" value="Search"  ajax="False"/>

2 个答案:

答案 0 :(得分:1)

filter.finder方法不是JSF Action方法。这是签名的方法

public String methodName()

这在股票标准JSF中不起作用。我会详细介绍JSF文档中的操作方法。

答案 1 :(得分:0)

如果您想搜索仅为小写的文件,您还写过可以使用.toLowerCase()。但这种情况并非如此。

如果你想按照lexiographical的顺序在它们中订购,那么它只会让字母看作全部小写。

相关问题