我正在從seam 2.2(jsf 1.2,jboss6)到seam 2.3(jsf 2,jboss 7)進行遷移並發現奇怪的行爲。我能與聯繫列表例如重現它:在seam 2.3中使用jstl標籤而沒有長時間運行的對話不起作用
編輯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標籤而沒有長時間運行的對話不能使用接縫2.3?
JSTL在視圖構建時運行,而不是視圖渲染時。相關:http://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – BalusC 2013-03-13 22:45:31
我不知道你的答案如何與我的問題有關。爲什麼使用長時間運行的對話「修復」問題?爲什麼在2.2接縫中沒問題,而且接縫2.3不能使用? – 2013-03-14 22:32:08