aspose file tools*
The moose likes JSF and the fly likes Commandlink not calling method in the bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Commandlink not calling method in the bean" Watch "Commandlink not calling method in the bean" New topic
Author

Commandlink not calling method in the bean

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
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

Joined: Jun 25, 2001
Posts: 16240
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
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

Joined: Jan 09, 2008
Posts: 86
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

Joined: Dec 02, 2000
Posts: 362
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

Joined: Jan 09, 2008
Posts: 86
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

Joined: Dec 02, 2000
Posts: 362
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

Joined: Jan 09, 2008
Posts: 86
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):

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Commandlink not calling method in the bean