1 Reply Latest reply on Jun 2, 2009 6:52 PM by marcelomagno

    Resetting EntityHome

    germandev.net-seam.wje-online.de

      Hi!


      I use a class extended from EntityHome<MyEntity> (only) to create respectively persist new instances.


      To do that I created a Facelets page with some h:inputText fields like


      <h:inputText value="#{myEntityHome.instance.property}" />
      <!-- few more input fields -->
      <h:commandButton action="{myEntityHome.persist}" value="Create" />
      



      it works and the Entity is persisted. But the values I have entered are still inside the text fields. If I click the create button another Entity with the same values is created and persisted.


      So I scoped the EntityHome to the Event scope and thought, the values won't survive after the persist event is over, but it's still the same result. As a 'dirty workaround' I tried to override the persist method of the EntityHome instance like


      @Override
      public String persist()
      {
           String ret =  super.persist();
           this.setInstance(null);
           this.setId(null);
           return ret;
      }
      



      but that didn't solve the problem.


      Why do the values I have entered survive the Event scope?
      What can I do to clear the fields after an Entity has been persisted?


      Thank you in advance!