IceFaces - commandButton не возвращает привязку

CommandButton не возвращает вложение (текстовый файл) из действия. У меня нет ошибок. Просто ничего не случилось.

Java-код:

 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>

Я пытаюсь использовать commandButton, потому что я не могу использовать ice:outputResource.

1 ответ

Вы можете использовать ice:outputResource как невидимую кнопку на сайте. Когда пользователь нажимает commandButton, вы можете вызвать что-то вроде "onClick" на льду: outputResource с использованием javaScript.

Другие вопросы по тегам