0

私はリッチフェイス4でjsf 2に取り組んでいます。拡張データテーブルからレコードを選択し、選択に基づいてXMLをダウンロードする必要があります。

ダウンロードを実装するために、BalusC がJSF アプリケーションから任意の Web ブラウザからダイアログとして保存を強制するで言及したアプローチに従いました。

私のコードは以下の通りです。

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 がレンダリングされないことです。そのため、ダウンロード用に選択されたチェック ボックスの値はクリアされません。助言がありますか?

4

1 に答える 1