[jboss-user] [JBoss Seam] - End conversation context

ebu do-not-reply at jboss.com
Sat Jan 6 20:14:44 EST 2007


Hi,
I can't understand why conversation context is not deleted when method annotated as @End is being called. Here is the code:


  | @Stateful
  | @Name("editSomething")
  | public class EditSomething implements EditSomethingLocal {
  |     @PersistenceContext
  |     EntityManager em;
  | 
  |     @Resource
  |     SessionContext ctx;
  | 
  |     @In
  |     Context sessionContext;
  | 
  |     @In(create=true)
  |     @Out
  |     Something something;
  |     
  |     @In(create=true)
  |     FacesMessages facesMessages;
  | 
  |     @Begin(join=true)
  |     public void prepare(){
  |     	System.out.println("prepare");
  |     }
  | 
  |     @End(beforeRedirect=true)
  |     public void create(){
  |     	em.persist(something);
  |     }
  | 
  |     @Remove
  |     @Destroy    
  |     public void remove(){
  |     	
  |     }
  | }
  | 

form to create:

  |                 <h:form>
  |                     <table border="0">
  |                         <tr>
  |                             <td class="cntForm">Name</td>
  |                             <td class="cntForm">
  |                                 <h:inputText id="name" required="true" value="#{something.name}">
  |                                     <s:validate />
  |                                 </h:inputText> *
  |                             </td>
  |                             <td><h:message for="name" styleClass="cntError" /></td>
  |                         </tr>
  |                     </table>
  | 
  |                     <h:commandButton action="#{editSomething.create}" value="Create" />
  |                 </h:form>
  | 
  | 

The first entity is created ok, but when then the form is displayed  the input field contains name of the created item, and when Create button pushed secnod time i'm  getting 


  | javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist
  | 

that's clear - since context was not destroyed the entity stored in it got detached and when again was passesed to persist  causes exception. But according to seam docs

anonymous wrote : 
  | When an @End method is encountered, any long-running conversation context is demoted to a temporary conversation
  | 

and 

anonymous wrote : 
  | At the end of the restore view phase of the JSF request lifecycle, Seam attempts to restore any previous long-running conversation context. If none exists, Seam creates a new temporary conversation context.
  | 

Thus, if existing contex was demoted to temporary one seam should create new temporary conversation context (and create new Something in it!) which in it's turn should be promoted to the long running conversation when prepare() is called...

What do i miss?

wbr, eugen.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3998610#3998610

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3998610



More information about the jboss-user mailing list