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 7705651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:55:01+00:00 2026-05-31T23:55:01+00:00

I have a fileDownload component inside a dataTable but when I click it it

  • 0

I have a fileDownload component inside a dataTable but when I click it it seems the filedownloader is called before the datlis.filepath variable is set by setPropertyActionListener.

When I click download I get “Cant instantiate class: ui.FileDownloader.com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: ui.FileDownloader.”

My jsf code is:

<p:column headerText="Metadata" style="width:40px">  
   <p:commandButton id="selectButton" rendered="#{datlis.has_metadata}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
      <f:setPropertyActionListener value="#{datlis.filepath}" target="#{filedownloader.filepath}" />  
      <p:fileDownload value="#{filedownloader.file}" /> 
   </p:commandButton>  
</p:column>  

The bean that ‘datlis’ represents is ViewScoped in my application – and I’ve checked that datlist.filepath is not null. And the file download bean (FileDownloader) is as follows:

@ManagedBean(name="filedownloader")
@RequestScoped
public class FileDownloader {  

private StreamedContent file; 

public StreamedContent getFile() {  
    return file;  
}

@ManagedProperty(value="#{param.filepath}")
private String filepath;

public String getFilepath() {
    return filepath;
}
public void setFilepath(String filepath) {
System.out.println("> "+filepath);
    this.filepath = filepath;
System.out.println(">> "+this.filepath);
}

public FileDownloader() throws FileNotFoundException { 
System.out.println("100");
    String filename = "/opt/glassfish3/glassfish/domains/domain1/datasets/string_compare/Business v2 Metadata/README.txt";
        InputStream stream = new FileInputStream(filepath);
        file = new DefaultStreamedContent(stream, "text/txt", "README.txt");  
}  

The stack trace mentions a nullpointer exception regarding the inputstream and that’s why I’m thinking the ‘filepath’ variable isn’t being set – plus my system output only shows the “100” from the System.out.println, and no System outputs from the setFilepath function…as if it’s not called at all.

I’ve also tried:

<p:column headerText="Metadata" style="width:40px">  
                <p:commandButton id="selectButton" rendered="#{datlis.has_metadata}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
                    <f:param name="filepath" value="#{datlis.filepath}" />  
                    <p:fileDownload value="#{filedownloader.file}" /> 
                </p:commandButton>  
            </p:column>

with the added code just above the filepath getter/setter in my FileDownloader class:

@ManagedProperty(value="#{param.filepath}")
private String filepath;

But this also doesn’t seem to work. Any ideas? I feel I’m on the right track perhaps just misusing the elements…

  • 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-05-31T23:55:02+00:00Added an answer on May 31, 2026 at 11:55 pm

    Managed properties will be injected after construction. So you will get an NPE if you try to access them in the bean’s constructor.

    Use a method annotated with @PostConstruct. It will automatically be invoked after construction and property injection:

    @PostConstruct
    public void init() {
      // do your initializations here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in javascript called dumpData which I call from a button
I have been trying to download the ASP .NET AJAX Futures but I can
I have a home page home.html inside a war file named webapp-1.0.war. When the
I have a download action implemented on my Vaadin application but for some reason
I have set of components that i wish to let the users download from
Does anyone have any examples of starting the file stream before the rendering/building process
I am jQuery newbie and I have been trying to set up a file
We have a number of PDFs hosted using Lighttpd but when they are downloaded
I have read many solutions but I haven't got the working one yet. My
Have a set of prototype-enabled ajax code that is working in all browsers other

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.