3 Replies Latest reply on Oct 23, 2008 7:43 PM by Andy Gibson

    oh my god....info for those using a table

    Dean Hiller Expert

      question for advanced users near the bottom, but the rest of this is to help other people using tables and a very weird quirk you really really need to know about tables.


      I ran into this issue twice now(The first time, I did not realize what it was, gave up and worked around, but was still annoyed).  Be very careful when you use a table and what variable name you will use or you will get very adverse affects.  We had two very different looking bugs(one was an LIE).  This should really be documented in the docs for people.


      Let's say you have a table and a entity bean and action bean below....


      Table


      <h:dataTable id="scriptTable" border="1" value="#{scripts}"
                var="s" rendered="#{scripts.size>0}">                                        
           <h:column>
               <f:facet name="header">Script Name</f:facet>
               #{script.name}
           </h:column>
           <h:column>
               <f:facet name="header">Actions</f:facet>
               <s:link id="editScript" value="Edit" action="#{editScript.editScript(script)}"/>
           </h:column>
      </h:dataTable>     
      



      Entity Bean


      @Entity
      @Name("script")
      @Scope(ScopeType.CONVERSATION)
      public class ScriptModel
      



      Action Bean



      @Name("editScript")
      @Scope(ScopeType.CONVERSATION)
      public class EditScriptAction {
      
           @In
           private EntityManager mgr;
           
           @In(required=false)
           @Out
           private ScriptModel script;
           
           @Begin(flushMode=FlushModeType.MANUAL)
           public void editScript(ScriptModel s) {
                script = mgr.find(ScriptModel.class, s.getId());
                
           }




      Step 1. Click edit on the table
      result 2. script variable from table is injected INTO the 
                bean.  Let's say this instance of the script is id=191
      result 3. editScript is called with script id=191
      result 4. mgr.find(script.getId()) returns a script instance of
                id=255
      result 5. script of id=255 SHOULD BE OUTJECTED INTO CONVERSATION!!!  
      result 6. script of id=255 SHOULD BE injected into the next bean being used to render the page
      result 7. script.getChildren SHOULD NOT throw LIE but does because the script is id=191 even though it was outjected into the conversation
      NOTE:  All of these id's were just taken from eclipse as I debugged the problem.  
      
      QUESTION: To see the hibernate cache and what is going on, I look
      at entityMgr.delegate.session.persitenceContext.entitiesByKey.  I
      would very much LIKE to inject a seam component of some sort that
      I can also peak into during debug mode to see what objects exist in the conversation.  What component could do this and what would
      be the variable path(like hibernates path above)?
      



      LESSON LEARNED: Don't use the same variable name in the table as on a bean!!!  There seems to be some kind of bug in seam around this.  We ran into it twice and each time it caused different problems...one was the LIE.....another was when doing a pulldown the value the user set did not exist in the list(ie. value inthe list was id=191 and set value was id=255 because outjection was not replacing the bean properly as the beans where the same)


      Extreme Software LLC