Note that there are some explanatory texts on larger screens.

plurals
  1. POjavax.el.PropertyNotFoundException:Property not found on type java.io.File in primefaces download
    primarykey
    data
    text
    <p>I am using Primefaces 3.2 and developing the file download functionality and I am getting list of file names from my local which i wanted to display them in jsf datatable with clickable option(h:commandlink).</p> <p>When I excute my Code I am getting following exception.</p> <blockquote> <p>javax.el.PropertyNotFoundException: /faces/fileDownload.xhtml at line 33 and column 115 value="#{x.fileName}": Property 'fileName' not found on type java.io.File</p> </blockquote> <p>My Code looks like this Java File</p> <pre><code>import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.StreamedContent; @ManagedBean(name="fileDownloadController") @SessionScoped public class FileDownloadController { private StreamedContent file; private List&lt;File&gt; listfiles=new ArrayList&lt;File&gt;(); private String fileName; public FileDownloadController() { File filestream=new File("C:/temp.pdf"); InputStream stream=null; try { stream = new FileInputStream(filestream); file = new DefaultStreamedContent(stream, "application/pdf", "temp.pdf"); stream.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public List&lt;File&gt; getListfiles() { File folder = new File("c:\\"); File[] listOfFiles = folder.listFiles(); listfiles=Arrays.asList(listOfFiles); int i; for(i=0;i&lt;listfiles.size();i++){ System.out.println("The List of file are"+listfiles.get(i)); listfiles.get(i); } return listfiles; } public void setListfiles(List&lt;File&gt; listfiles) { this.listfiles = listfiles; } public String getFileName() { getListfiles(); return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public StreamedContent getFile() { return this. file; } } </code></pre> <p>My XHTML looks like this.</p> <pre><code>&lt;h:form id="form"&gt; &lt;h:dataTable value="#{fileDownloadController.listfiles}" var="x" bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" first="0" rows="4" width="50%" summary="This is a JSF code to create dataTable."&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="File Names"&gt;&lt;/h:outputText&gt; &lt;/f:facet&gt; &lt;h:commandLink value="#{x.fileName}" onclick="PrimeFaces.monitorDownload(showStatus, hideStatus)"&gt; &lt;p:fileDownload value="#{fileDownloadController.file}" /&gt; &lt;/h:commandLink&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;/h:form&gt; </code></pre> <p>I am not able to figure out where i went Wrong.Please help me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload