seam 2.3 jstl tags without long running conversation
petros Mar 15, 2013 9:13 AMHi all,
I'm doing migration from seam 2.2 (jsf 1.2, jboss6) to seam 2.3 (jsf 2, jboss 7) and found strange behavior. I was able to reproduce it with contact-list example:
edit viewContact.xhtml page and replace this fragment:
<h3> <h:outputText id="Comments" value="Comments" rendered="#{not empty contact.comments}" /> <h:outputText id="noComments" value="No Comments" rendered="#{empty contact.comments}" /> </h3>
with something like this:
<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>
(don't forget to add namespace xmlns:c="http://java.sun.com/jsp/jstl/core")
I known that change has no sense - it only demonstrates my problem.
After rebuild/redeploy when you go to viewContact page and try to add any new comment you will get:
Exception during request processing:
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"
Now let's do some other changes to begin long running conversation after entering viewContact page (and end it after persisting comment)
In pages.xml insert this fragment:
<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>
In viewContact.xhtml change submit button:
<h:commandLink id="submit" action="#{commentHome.persist}" value="Create Comment" > <s:conversationId/> </h:commandLink>
Now, after redeploy, new comment can be added - no exception is thrown.
Can someone explain to me why using jstl tags without long running conversation is not working with seam 2.3?
UPDATE
I askes same question on stackoverflow (http://stackoverflow.com/questions/15361513/using-jstl-tags-in-seam-2-3-without-long-running-conversation-is-not-working) and got answer:
"JSTL runs during view build time, not during view render time. Related: stackoverflow.com/questions/3342984/… – BalusC" but have no idea how it can be related to long running conversations.