seam 2.2 (jsf 1.2、jboss6) から seam 2.3 (jsf 2、jboss 7) への移行を行っていますが、奇妙な動作が見つかりました。連絡先リストの例で再現できました:
viewContact.xhtml ページを編集して、次のフラグメントを置き換えます。
<h3>
<h:outputText id="Comments" value="Comments" rendered="#{not empty contact.comments}" />
<h:outputText id="noComments" value="No Comments" rendered="#{empty contact.comments}" />
</h3>
このようなもので:
<c:if test="#{not empty contact.comments}">
<h3><h:outputText value="Comments" /></h3>
</c:if>
<c:if test="#{empty contact.comments}">
<h3><h:outputText value="No Comments" /></h3>
</c:if>
(名前空間を追加することを忘れないでくださいxmlns:c="http://java.sun.com/jsp/jstl/core"
)
変更に意味がないことはわかっていました。それは私の問題を示しているだけです。
viewContactページに移動して新しいコメントを追加しようとすると、再構築/再デプロイした後、次のようになります。
リクエスト処理中の例外:
Caused by javax.servlet.ServletException with message: "java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.jboss.seam.example.contactlist.Comment.contact -> org.jboss.seam.example.contactlist.Contact"
ここで、viewContact ページに入った後に長時間の会話を開始するために、いくつかの変更を加えてみましょう (そして、コメントを保持した後に会話を終了します)。
pages.xml に次のフラグメントを挿入します。
<page view-id="/viewContact.xhtml">
<begin-conversation />
<param name="contactId" value="#{contactHome.id}" converterId="javax.faces.Long" />
<navigation>
<rule if-outcome="persisted">
<end-conversation />
<redirect />
</rule>
<rule if-outcome="removed">
<redirect view-id="/search.xhtml" />
</rule>
</navigation>
</page>
viewContact.xhtml で送信ボタンを変更します。
<h:commandLink id="submit" action="#{commentHome.persist}" value="Create Comment" >
<s:conversationId/>
</h:commandLink>
再デプロイ後、新しいコメントを追加できるようになりました - 例外はスローされません。
長い会話なしで jstl タグを使用すると seam 2.3 で動作しない理由を誰かが説明してくれますか?