Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:36:45+00:00 2026-06-11T07:36:45+00:00

I am using Primefaces 3.2 and developing the file download functionality and I am

  • 0

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).

When I excute my Code I am getting following exception.

javax.el.PropertyNotFoundException: /faces/fileDownload.xhtml at line
33 and column 115 value=”#{x.fileName}”: Property ‘fileName’ not found
on type java.io.File

My Code looks like this Java File

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<File>  listfiles=new ArrayList<File>();
    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<File> getListfiles() {
        File folder = new File("c:\\");
        File[] listOfFiles = folder.listFiles();
        listfiles=Arrays.asList(listOfFiles);
        int i;
        for(i=0;i<listfiles.size();i++){
       System.out.println("The List of file are"+listfiles.get(i));
       listfiles.get(i);
        }
        return listfiles;
    }

    public void setListfiles(List<File> listfiles) {
        this.listfiles = listfiles;
    }

    public String getFileName() {
        getListfiles();
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public StreamedContent getFile() {
        return this. file;
    }
}

My XHTML looks like this.

<h:form id="form">  
 <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.">
              <h:column>
                <f:facet name="header">
                <h:outputText value="File Names"></h:outputText>
                </f:facet>
                <h:commandLink value="#{x.fileName}" onclick="PrimeFaces.monitorDownload(showStatus, hideStatus)">
                        <p:fileDownload value="#{fileDownloadController.file}" />
                </h:commandLink>
             </h:column>
               </h:dataTable> 
</h:form>  

I am not able to figure out where i went Wrong.Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:36:47+00:00Added an answer on June 11, 2026 at 7:36 am

    How did you come to using #{x.fileName}? Look carefully in the javadoc of the java.io.File class. Right, there’s no such method like getFileName(). That’s exactly what the exception is trying to tell you.

    value=”#{x.fileName}”: Property ‘fileName’ not found on type java.io.File

    Most likely you meant to use the getName() method instead.

    #{x.name}
    

    Unrelated to the concrete problem, your code would be more self-documenting if you used var="file" instead of the nonsensicial var="x".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Java web application using Hibernate and JSF/primefaces. am sometimes getting
I am using primefaces autocomplete componant for multiple columns. I am able to display
Hello i am using primefaces version 3.2 The ui layout which i am using
I recently migrated my JSF app(using primefaces) from glassfish 3.1 to tomcat7 server. Previously
I'm using primefaces' accordion panel. Inside the tabs i have forms which are created
I'm developing a web app using JSF 2.0 + PrimeFaces 2.2.1 Now I think
I am new to Eclipse. Currently developing a sample web application using primefaces 3.1
I'm using primefaces and jstl to loop a datatable.I have a List in backing
We are using Primefaces 3M4 and one of our pages has a p:dataTable which
I know how to do file upload using Primefaces or using Tomahawk, however, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.