Reputation: 1230
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?
Upvotes: 1
Views: 615
Reputation: 1230
Solution for this issue is turning off partial state saving. Just add this to the web.xml:
<context-param>
<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
<param-value>false</param-value>
</context-param>
Upvotes: 1