3 Replies Latest reply on Mar 28, 2008 1:32 PM by Pete Muir

    entityHome remove is not firing afterTransactionSuccess

    Mike Kabir Newbie

      In components.xml





      <event type="org.jboss.seam.afterTransactionSuccess.Stuff">
         <action execute="#{myStuff.refresh}" />
      </event>
      
      <framework:entity-query name="myStuff"
              ejbql="from Stuff s where s.userByOwnerId = #{currentUser} 
              order="stuffName"
               max-results="#{listStuff.pageSize}"
              >
         </framework:entity-query>





      In code



      StuffHome i = (StuffHome) Component.getInstance("stuffHome");
              i.setInstance(stuffForDeletion);
      
              i.setId(stuffForDeletion.getStuffId());
                i.remove();



      deletion happens ok. refresh does not. Any ideas, workarounds ?


      Thanks,


      KB

        • 1. Re: entityHome remove is not firing afterTransactionSuccess
          Mike Kabir Newbie

          Deletion is happening in a modal panel.

          • 2. Re: entityHome remove is not firing afterTransactionSuccess
            William Woodman Master

            having a similar problem I think - no soap at present


            heres what i have in code


            i have an entity class Node , a NodeHome, and NodeList.  The last two are seam conversational named classes.


            in my UI i have pageList.xhtml that displays the results from the NodeList framework backing bean.  in the UI if you want to add a new node theres a link to do this, and i start the node.xhtml as part of a nested conversation. 


            however when you persist the new node my NodeHome @Observer method is never called - so i get no auto refresh.


            here is part of the nodeList defn


            
            @Name("nodeList")
            
            @Scope (ScopeType.CONVERSATION)
            
            //@Conversational()
            
            public class NodeList extends PagedEntityQuery<Node>
            
            {
            
                 private static final long serialVersionUID = 1;
            
                 
            
                 private String searchString;
            
                 
            
                 /*declare the selected result to be injected on selection 
            
                 @DataModelSelection
            
                 Node node; */
            
                 
            
                 //@In 
            
                 //Node QBENode;
            
                 
            
                 
            
                 @Logger
            
                 private Log log;
            
                 
            
                @In FacesMessages facesMessages;
            
            
                @Observer ("org.jboss.seam.afterTransactionSuccess.Node")
            
                public void afterTransactionSuccess ()
            
                {
            
                     facesMessages.add("node list: refreshing list after successful transaction on nodeHome");
            
                     getResultList();
            
                }
            
            ...     
            
            



            equally in the NodeHome i ovverode the raise after transaction success method to check it was getting raised


            
            
            @Name("nodeHome")
            
            public class NodeHome extends EntityHome<Node>
            
            {
            
            
                @RequestParameter 
            
                 Long nodeId;
            
            
                 @Logger
            
                 private Log log;
            
                 
            
                @In FacesMessages facesMessages;
            
            
                // TODO debug event handling then get rid of 
            
                @Override
            
                protected String getEntityName()
            
                {
            
                     String en = super.getEntityName();
            
                     facesMessages.add ("got simple entity name of #0", (en != null) ? en : "<null>");
            
                     return en;
            
                }
            
            
                /**
            
                 * Raise events when a CRUD operation succeeds.
            
                 * <br />
            
                 * Utility method to raise two events: an event of type 
            
                 * <code>org.jboss.seam.afterTransactionSuccess</code> is raised, along with 
            
                 * an event of type 
            
                 * <code>org.jboss.seam.afterTransactionSuccess.&lt;entityName&gt;</code>.
            
                 */
            
                @Override
            
                protected void raiseAfterTransactionSuccessEvent()
            
                {
            
                     facesMessages.add("raising base trans success ");
            
                     raiseTransactionSuccessEvent("org.jboss.seam.afterTransactionSuccess");
            
                   String simpleEntityName = getSimpleEntityName();
            
                   if (simpleEntityName != null)
            
                   {
            
                        facesMessages.add("raising additional entity trans success #0", "org.jboss.seam.afterTransactionSuccess." + simpleEntityName);
            
                             raiseTransactionSuccessEvent("org.jboss.seam.afterTransactionSuccess." + simpleEntityName);
            
                   }
            
                }
            
            ...
            
            



            When i run the forms i can see the event being raised as shown here in the facesMessages log.


            
            created new NodeHome, start nested conversation
            
            nodeHome factory initialsed new node
            
            Successfully created
            
            raising base trans success
            
            got simple entity name of org.domain.ForstersList.entity.node.Node
            
            raising additional entity trans success org.jboss.seam.afterTransactionSuccess.Node
            
            



            however i get to see no refresh fired on the NodeList observer.


            my UI does not automatically refresh to show me the node just persisted.  I have to manually trigger a refresh action from the nodeList.xhtml form.


            Dear seam team any ideas whats not happening - is it a bug?

            • 3. Re: entityHome remove is not firing afterTransactionSuccess
              Pete Muir Master

              Attach a debugger and see where the event raise goes wrong.