4 Replies Latest reply on Jan 16, 2013 12:54 PM by Eduardo Ribeiro Silva

    Seam+CDI Event Probleam - Observer does not work

    Eduardo Ribeiro Silva Newbie

      Hi all,

       

      I'm in trouble with Observers.

      I have a superclass that fire event and another class responsible for observe the event, but it's not working.

       

      My superclass:

       

      public abstract class AbstractCrudModel<T> implements Serializable {

       

          @Inject

          @Update

          protected Event<T> evtUpdate;

       

          public String update() {

              T loaded = findSelectedById();

             

              if (loaded != null) {

                  T t = doUpdate();

                  if (t != null) {

                      evtUpdate.fire(t);

                  }

              } else {

                  messages.warn(new BundleKey("messages", "registro_nao_encontrado_atualizacao"));

              }

             

              list = queryList();

             

              return crudController().urlBegin();

          }

      }

       

      My concrete model class:

       

      @Stateful

      @ConversationScoped

      @Model

      public class ManterTipoAutorizacaoModel extends AbstractCrudModel<TipoAutorizacao> {

       

          @Override

          public TipoAutorizacao doUpdate() {

              dao.merge(entitySelected);

             

              return entitySelected;

          }

      }

       

      My Observer:

       

      public class PersistenceEvent {

         

          @Inject

          private Messages msg;

       

          public void onAtualizar(@Observes(during=TransactionPhase.AFTER_SUCCESS) @Update final TipoAutorizacao tipoAutorizacao) {

              msg.info(new BundleKey("messages", "registro_atualizado_sucesso"));

          }

      }

       

      Any idea?