5 Replies Latest reply on Oct 23, 2007 9:55 AM by Pete Muir

    Remove variable from page context via Contexts.removeFromAll

    Jonas Buechel Novice

      I'm trying to remove desperately a variable from the page context via the Contexts.removeFromAllContexts() method, but it didn't work.
      This is the code:

      @Scope(ScopeType.PAGE)
      @Name("personAction")
      public class PersonActionImpl {
      
       @Logger
       Log log;
      
       @In(required = false)
       @Out(required = false)
       private Person personDataModelSelection;
      ...
      
       public void deletePerson() {
       log.debug("deletePerson() called");
       personService.removePerson();
       personDataModelManager.initializeModel();
       log.debug("personDataModelSelection: #0", Contexts
       .lookupInStatefulContexts("personDataModelSelection"));
       Contexts.removeFromAllContexts("personDataModelSelection");
       log.debug("personDataModelSelection: #0", Contexts
       .lookupInStatefulContexts("personDataModelSelection"));
      
       personDataModelSelection = null;
       }
      ...
      



      Output:
      17:31:25,460 DEBUG [PersonActionImpl] personDataModelSelection: [Person -> CoreId="99991234567812345678ABC123"; Firstname="Hansi 123"; Lastname="Meier123"]
      17:31:25,460 DEBUG [PersonActionImpl] personDataModelSelection: [Person -> CoreId="99991234567812345678ABC123"; Firstname="Hansi 123"; Lastname="Meier123"]
      


      Shouldn't it be removed at the 2nd output line?
      Btw, it works if i declare the class in conversation scope..
      I can't see what i'm doing wrong..