Question

Hi i have a command button.

I am using jsf 1.12 and tomahwak. I also am using jquery on client side.

<h:commandButton type="submit" value="Download Receipt" 
                 onclick="refresh();" 
                 id="downloadDocument"
                 actionListener="#{transactionPage.downloadReceipt}" 
                 immediate="true"
                 /> 

My jsf backing bean function

public void downloadReciept(final ActionEvent event) {
    try{
        DocManager docManager = new DocManager();
        docManager.printDocs();
    }catch (Exception e) {
        log.error("Fail to download document!", e);
    }
}

print docs would just create a file and stream it by setting the content-type, response, etc.

        File sourceFile = createDoc();
        Url url         = sourceFile.toURI().toURL();
        streamDoc(url);

I want to be able to display a message when downloading is starting and message when it finished

No correct solution

OTHER TIPS

Hi thanks found my solution.

I change to commandLink than

set the cookie in backend and use jquery's file download

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top