richfaces가있는 jsf 2에서 작업 중입니다. 확장 데이터 테이블에서 레코드를 선택하고 선택에 따라 XML을 다운로드해야한다는 요구 사항이 있습니다. 다운로드를 구현하기위한파일 다운로드 후 확장 데이터 테이블 렌더링
, 나는 내 코드는 다음과 같습니다 Forcing a save as dialogue from any web browser from JSF application
에 BalusC에 의해 언급 된 접근 방식을 따랐다.
XHTML File
----------
<h:commandButton id="Download" value="#{msg.buttonDownload}"
action="#{studentMBean.downloadStudent}"
render="studentTable,datascroller" immediate="true">
</h:commandButton>
downloadStudent method
----------------------
Student student = studentSvc.downloadStudent(studentMap);
JAXBContext jaxbContext = JAXBContext.newInstance(Student.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
response.reset();
response.setContentType("application/xml");
response.setHeader("Content-disposition", "attachment; filename=\"studentData.xml\"");
jaxbMarshaller.marshal(student, response.getWriter());
response.getWriter().close();
facesContext.responseComplete();
여기서 문제는 파일 다운로드 후 studentTable 및 dataScroller가 렌더링되지 않는다는 것입니다. 따라서 다운로드하도록 선택된 확인란 값은 지워지지 않습니다. 제안 사항이 있으십니까?