4 Replies Latest reply on Sep 5, 2007 9:30 AM by Pete Muir

    Using @DataModel and @DataModelSelection in different Sessio

    Manuel Zabelt Newbie

      Hi,

      I want to separate DataProviding and EventHandling in my application
      as much as possible. That's why I'm thinking of using one SessionBean
      to provide DataModel for my facelets. Actions, that later will be triggered
      from within the facelet by user events, should then be handeled in some
      other session bean. I had two ideas on how to implement this, but none
      succeeded. Could someone point me into the right direction?

      Idea1:

      @Stateful
      public class DataProviderBean implements IDataProviderBean{
      
       @DataModel("entities")
       List<Entity> e;
      
       @Factory("e")
       public void initE(){ ... }
      }
      
      @Stateful
      @Name("EventHandler")
      public class EventHandler implements IEventHandler{
       @DataModelSelection(value="entities")
       Entity e;
      
       public event1(){
       // do some reasonable thing with e
       }
      }
      


      This unfortunatelly does not even deploy, since seam tells me,
      that it needs a @DataModel for each @DataModelSelection
      within EventHandler.

      My second idea was as follows:

      @Stateful
      public class DataProviderBean implements IDataProviderBean{
      
       @DataModel("entities")
       List<Entity> e;
      
       @DataModelSelection(value="entities")
       @Out("selectedEntity")
       Entity e;
      
      
       @Factory("e")
       public void initE(){ ... }
      }
      
      @Stateful
      @Name("EventHandler")
      public class EventHandler implements IEventHandler{
       @In("selectedEntity")
       Entity e;
      
       public event1(){
       // do some reasonable thing with e
       }
      }
      
      


      But EventHandler.e did never get initialized with anything else than null.

      Any ideas?

      thanks and greetings
      barfoos