Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commandlink not calling method in the bean

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



I have other fields in the form,
On click of the download link, the page simply refreshes but doesn't call the fileDownload method in the bean...any idea where am wrong?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's generally one of 2 things:

1. You didn't declare fileDownload as a public no-argument method returning a String in the backing bean.

2. You have a problem with some of the data that's being sent when you click the link. The JSF messages tag will usually display a message, if that's the problem.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my filedownload method.. It doesn't even log the first log message


[ March 28, 2008: Message edited by: Mary Cole ]
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is an action (as opposed to actionListener) it should return a String. the string triggers navigation.

Also you want to ensure there are no javascript errors on your page.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with the action listenertoo...with no luck. The form has many other fileds with a link to the download field. I have 2 different beans in the form and the commanlink for one of the form works and downloads the file...but the same code for the other form and other bean in the same page doesn't call the method. The form gets submitted populationg the bean except calling this method
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any javascript errors on the page? If you are using IE, look in the bottom left corner of status line...Done it say 'Done' or 'Error'?
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was calling the filedownlad method using a command link and sepecifying the action as beanname.fileDownload. The problem which am facing now is , the response i get contains the whole file (from DB)inaddition to the html elements which is on the form. as the page refreshes on click of the link .. Is there any way to download only the file contents ignoring the other fields which is on the page and without submitting the whole page.
[ April 03, 2008: Message edited by: Mary Cole ]
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This kind of code will send a file to the browser. It assumes 'doc' has the file contents. Make sure file has a known extension (pdf, doc, rtf, etc):

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic