JSF如何在bean

时间:2018-06-13 16:07:59

标签: primefaces actionlistener commandbutton uirepeat backing-beans

我想知道我是否可以将commandButton的值传递给Bean? Bean Name是“fileDownloadView”。 但是值始终为null。 bean中的值应存储在cbtValue中。 提前谢谢。

示例代码:

    <ui:repeat value="#{data.linkListen}" var="linkListe" varStatus="status">
                <h:commandButton value="#{linkListe.name}" ajax="false" actionListener="#{fileDownloadView.prepare()}">
                   <p:fileDownload value="#{fileDownloadView.filedownload}"/>
                </h:commandButton>
    </ui:repeat>

我试图使用:

豆:

private String cbtValue

public void prepare() throws Exception{
    flpath = path + cbtValue;
    File file = new File(flpath );
    InputStream input = new FileInputStream(file);
    String mimeType = Files.probeContentType(Paths.get(flpath ));
    setFiledownload(new DefaultStreamedContent(input, mimeType, file.getName()));
}

//getter, setter Methods

0 个答案:

没有答案