nullpointer exception on filedownload

UI Components for JSF
Post Reply
lordpixel
Posts: 134
Joined: 17 Jun 2010, 17:46

29 Sep 2010, 17:00

Hi all
hi have a button rendered in a datatable that download a file.
Now the button is always present but the download may fail because the file is passe by a web service and i know that there is not file only when i call web service and not when i render the button.
Now when i click the button and the StreamedContent is null the page "explodes" ^^ and i get a bad nullpointer exception. Even if i use try catch statements...
There is something to return different from a null when there is no file?

Thanks

dacian275
Posts: 95
Joined: 10 Sep 2010, 17:34

29 Sep 2010, 18:38

You could have boolean value fileIsNull in your code that checks whether the file is null. Then, you could use the rendered or disabled attribute for button so that users can't download when the file is null.

lordpixel
Posts: 134
Joined: 17 Jun 2010, 17:46

30 Sep 2010, 11:44

I've fixed testing null before return . If the file is null i create a streamcontent from a fixed pdf file containing an alert....

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests