I want to show dialog box to save the file (to select the path where you want to save the file) while clicking the download button using PrimeFaces. How can I achieve this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
The PrimeFaces
<p:fileDownload>tag has thecontentDispositionattribute for that which you could set toinline(to display the file inline) orattachment(to pop a Save As dialogue).However, it defaults to
attachmentalready! You shouldn’t have the need to explicitly specify it.So your concrete problem is caused by your webbrowser itself. Most modern webbrowsers can be configured to take specific default actions when a file of a specific content type is been retrieved. Apparently yours is configured to always display it inline regardless of the content disposition. It’s unclear which webbrowser you’re using, but the way how Firefox handles it is the most commonly known and confusing among starters, so I’ll target my answer on it.
When you download for example a PDF file in Firefox, it’ll by default show you a dialog with 2 options: open it (inline) in Adobe, or save it to disk. Below that, there’s a checkbox to remember the default action.
Apparently you’ve ever ticked that while the option is set to open the file inline and this way Firefox will never ask you anymore whether to open or to save it.
You can reconfigure this by Tools > Options > Applications.