IceFaces - commandButton doesn't return attatchment

87 views Asked by At

CommandButton doesn't return attachment (txt file) from action. I have no errors. Just nothing happend.

Java code:

 FacesContext facesContext = FacesContext.getCurrentInstance();
 HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
 response.setContentType("application/txt");
 response.setHeader("Content-Disposition","attachment;filename=file.txt");
 IOUtils.copy(new StringReader("TEST"), response.getOutputStream());
 facesContext.responseComplete();
 facesContext.renderResponse();

iceFaces - jspx

            <ice:commandButton 
                id="downloadBtn" 
                action="#{contentsBean.downloadAsZip}" 
                value="txt" partialSubmit="true" immediate = "true" >       
            </ice:commandButton>

I try to use commandButton, because i can't use ice:outputResource.

1

There are 1 answers

0
sszledak On

You can use ice:outputResource as invisible button on website. When user will click commandButton you can induce something like "onClick" on ice:outputResource with using javaScript.