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

  • Home
  • SEARCH
  • 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 6793503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:06:30+00:00 2026-05-26T18:06:30+00:00

A command link is present on the JSF page. When the link is clicked,

  • 0

A command link is present on the JSF page. When the link is clicked, a modal is opened.
The download button in the modal is selected, validation takes place for the input fields and then a file is downloaded. The requirement is to close the modal and return to the same page after successful download of the file. How can we close the modal when the Open File dialog is showing up on the same page.

<h:panelGroup rendered="#{downloadBacking.showDownloadModal}">
    <ui:include src="DownloadFile.xhtml" />
</h:panelGroup>

showDownloadModal field is defined in viewscoped bean.

When download button in modal is clicked, the downloadFile() method is called.

public String downlaodFile(){
    // response.getwriter.write(string);
    showDownloadModal = false;
    return "";
}
  • 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-26T18:06:30+00:00Added an answer on May 26, 2026 at 6:06 pm

    Your downloadFile() method won’t work that way. You can send only one response per request. A file download is at its own already a whole response. You cannot append another data to it; it would only corrupt the downloaded file with that data. Or, if you’ve written the download file code properly, you should also have seen an IllegalStateException: response already committed.

    You have 2 options:

    1. Close the dialog immediately on click of the download link with help of some JS code.

      <h:commandButton value="Download" action="#{bean.downloadFile}" 
          onclick="some JS code here to hide the modal" />
      
    2. Save the file server’s temp disk (or as byte[] in memory if it isn’t large) and return to the same page wherein you hide the dialog and conditionally render some JS window.location which points to that file. This is particularly useful if the to be downloaded file actually needs to be created/generated first which may be time consuming.

      <h:panelGroup rendered="#{bean.downloadReady}">
          <script>window.location = '#{bean.downloadURL}';</script>
      </h:panelGroup>
      

      The URL can point to a simple servlet which streams the file from disk or memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Explanation: I have a JSF command link that sets a member in the backing
I have a page which takes in request params for place, then generate information,
I have a page with something like this: <input type=button onclick=confirm('confirm popup'); value=click />
There's a #pragma command to link in a library from the source file rather
I tried to execute the DESCRIBE command via a database link, but this was
I am trying to add an ActiveX command button in my work sheet at
This is a Windows Vista Command Link dialog: alt text http://i.msdn.microsoft.com/Aa511455.commandlinks01(en-us,MSDN.10).png I was wondering
My makefile defines a link command: prod_link = $(LINK) $(LINK_FLAGS) -o$(PROD_OUT) $(PROD_OBJS) where $(PROD_OBJS)
Link to command pattern Why does the client have no reference to the invoker
I would like to generate the Link Button as below in code behind. <asp:LinkButton

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.