5 Replies Latest reply on Aug 14, 2007 9:18 AM by devx edg

    The method destroy is called twice

    devx edg Newbie

      Hi all. I have this:
      TableModel.java

      @Name("tableModel")
      @Conversational
      @Scope(ScopeType.CONVERSATION)
      public class TableModel {
      
       @In
       private EntityManager em;
      
       private List data;
      
       @Begin
       public void begin(Class entityClass) {
       data = query(entityClass);
       }
      
       @Destroy
       public void clean() {
       data.clear();
       data = null;
       }
      
       public List getData() {
       return data;
       }
      
       private List query(Class entityClass) {
       ....
       }
      }
      

      MenuManager.java
      @Name("menuManager")
      @Scope(ScopeType.SESSION)
      public class MenuManager{
      
       private TableModel tableModel;
      
       public String redirect() {
       if(tableModel != null) {
       tableModel.clean();
       }
       tableModel = (TableModel) Component.getInstance("tableModel", ScopeType.CONVERSATION);
       tabelModel.begin(SomeEntity.class);
       }
      }
      

      When I call "tableModel.clean()" the field "data" on TableModel is null.
      Then when the session is ended or the conversation timeout expire the method is called again, this is right?
      Any help, thanks.