<h:commandLink/>
JSF タグのアクション メソッドが呼び出されると、次のエラー メッセージが表示されます。
PWC3999: Cannot create a session after the response has been committed
エラー メッセージの意味は非常に単純ですが、私の質問は、アクション メソッドの実行が終了する前に応答がコミットされた可能性があるということです。
(このエラーは、commandLink がクリックされるたびに発生するのではなく、ときどき発生します。)
I use
JSF implementation: Mojarra V2.1.3
JSF component library: Primefaces V2.2.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
編集:これが解決策を得るのに役立つ場合は、いくつかのコードを以下に添付します:
マークアップ:
<h:commandLink value="[Log in]"
action="#{headerAndFooterTemplateBacking.loginFilter}"
disabled="#{sessionScope.pk > 0 ? true : false}"
styleClass="#{sessionScope.pk > 0 ? 'disabled' : 'notDisabled'} padding" immediate="true"/>
アクションメソッド:
public void loginFilter() {
String from = FacesContext.getCurrentInstance().getViewRoot().getViewId();
int pk = getSessionMap().get("pk") == null ? -1 : (Integer) (getSessionMap().get("pk"));
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
Object selected = request.getParameter("selected");
if (pk <= 0) {
if (selected != null) {
getSessionMap().put("from", from + "?faces-redirect=true&selected=" + selected);
} else {
getSessionMap().put("from", from + "?faces-redirect=true");
}
getFacesContext().getApplication().getNavigationHandler().
handleNavigation(getFacesContext(), null,
"/pages/login/login.xhtml?faces-redirect=true");
}
}