3 Replies Latest reply on Nov 23, 2009 6:48 PM by Fabio Montezuma

    Injection fail, design problems

    Fabio Montezuma Newbie

      Hi!


      I have an action bean that is getting too big because its page has some tricky manipulations.


      Trying to divide this bean, I created a property in it called events that instantiate another class called here ActionEvents (to manipulate form fields events).


      I have something like this:


      @Name("action")
      public class Action {
         @In
         private EntityManager entityManager;
      
         private ActionEvents events;
      
         public Action() {
            this.events = new ActionEvents(this);
         }
      
         // other methods   
      
         // getters and setters
      }



      public class ActionEvents {
      
         private Action action;
      
         public ActionEvents(Action action) {
            this.action = action;
         }
      
         public void select_onclick()
         {
            action.methodA();
            action.methodB();
         }
      }



      And the page:


      ...
      <h:selectOneRadio id="select">
         <s:selectItems ...>
         <a:support event="onclick" actionListener="#{action.events.select_onclick}" />
      </h:selectOneRadio>
      ...
      



      But when methodA is called inside select-onclick() the entityManager is null.


      Howto solve this? Does this design looks too bad?


      Thanks in advance!