[Seasar-user:9167] Re: [Teeda] ダウンロード時に発生するIllegalStateExceptionに

Shinpei Ohtani [E-MAIL ADDRESS DELETED]
2007年 7月 13日 (金) 17:50:36 JST


大谷です.

> 元々は、下記のソースのようにDIされたものではなく
> FacesContextを取得してやっていたのですが、これに
> 問題があったという認識でよいでしょうか?
> つまり、responseCompleteを発行する場合は、Seasar2では
> DIされたFacesContextに対してresponseCompleteを
> 発行しなければならないとなる認識になるのかと。

いえ、どちらも同一のFacesContextです.
特に違いは無いと思いますが.


07/07/13 に [E-MAIL ADDRESS DELETED]<[E-MAIL ADDRESS DELETED]> さんは書きました:
> 原田です。お世話になっております。
>
> 下記の件、うまく行きました。ありがとうございます。
>
> 元々は、下記のソースのようにDIされたものではなく
> FacesContextを取得してやっていたのですが、これに
> 問題があったという認識でよいでしょうか?
> つまり、responseCompleteを発行する場合は、Seasar2では
> DIされたFacesContextに対してresponseCompleteを
> 発行しなければならないとなる認識になるのかと。
>
> --------ソース---------
> // FacesContextからresponse取得
> FacesContext fctx = FacesContext.getCurrentInstance();
> ExternalContext ectx = fctx.getExternalContext();
> HttpServletResponse res = (HttpServletResponse) ectx.getResponse();
>
> // コンテキストタイプの設定
> res.setContentType(contentType);
>
> // ファイル名設定
> StringBuffer attachment = new StringBuffer();
> attachment.append("attachmenter;filename=");
> attachment.append(fileName);
> res.setHeader("Content-Disposition", attachment.toString());
>
> // 出力領域の設定
> ServletOutputStream outData = res.getOutputStream();
>
> // ファイルのバイナリ取得
> byte[]  fBuf = new byte[4096];
> int     readLen = 0;
>
> // ファイルを読込みレスポンスに書き込み
> while ((readLen = in.read(fBuf)) != -1) {
>
>     outData.write(fBuf, 0, readLen);
> }
> outData.flush();
> outData.close();
>
> fctx.responseComplete();
>
> 以上
>
>
> >ひがです。
> >>
> >> 本件ですが、すでにresponseCompleteは呼び出しています。
> >> ただし、JSF仕様で、FacesContextをDIせずにやっていたため
> >> ひがさんが言うようにDIしたfacesContextに対して
> >> responseCompleteをやってみましたがIllegalStateExceptionが
> >> 発生しました。
> >>
> >LifecycleImplの124行目を見るとわかりますが、
> >responseComplieteが呼び出されていれば、レンダリングや
> >フォワードは行われないはずです。
> >
> >FacesContextのresponseCompleteがTeedaが認識できる形で
> >呼び出されていないのではないかと思います。
> >
> >実はスレッドが違うとか、違うリクエストでresponseCompleteを
> >呼び出しているとか。
> >ダウンロードしたスレッドでresponseCompleteを呼び出せば
> >大丈夫なはずです。
> >
> >--
> >Yasuo Higa
> >[E-MAIL ADDRESS DELETED]
> >_______________________________________________
> >Seasar-user mailing list
> >[E-MAIL ADDRESS DELETED]
> >https://ml.seasar.org/mailman/listinfo/seasar-user
> >
> _______________________________________________
> Seasar-user mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-user
>


-- 
=============================
Shinpei Ohtani
[E-MAIL ADDRESS DELETED]
=============================



Seasar-user メーリングリストの案内