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

    Using @DataModel and @DataModelSelection in different Sessio

    barfoos

      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

        • 1. Re: Using @DataModel and @DataModelSelection in different Se
          pmuir

          1) Try @In("e.rowData")

          2) You need to call a method on DataProviderBean for the @DataModelSelection/outjection to happen.

          • 2. Re: Using @DataModel and @DataModelSelection in different Se
            barfoos

             

            "pete.muir@jboss.org" wrote:

            1) Try @In("e.rowData")

            I'll give this a try. Thanks


            2) You need to call a method on DataProviderBean for the @DataModelSelection/outjection to happen.


            I already tried to use setter and getter methods annotated with @DataModelSelection and @Out. I thought, that this
            way, seam would call these methods and thus would trigger
            the bijection mechanism. But this did not work. I don't know why.
            Maybe implicit method calls that are performed by the framework and
            not be my own code, does not trigger bijection at all?

            thanks for you help.



            • 3. Re: Using @DataModel and @DataModelSelection in different Se
              barfoos

               

              "barfoos" wrote:
              "pete.muir@jboss.org" wrote:

              1) Try @In("e.rowData")

              I'll give this a try. Thanks



              I gave it a try and got the following Exception:
              org.jboss.seam.RequiredException: In attribute requires non-null value: EventHandler.a.rowData
              


              Sorry. I'm feeling, that this all seems to be some trivial problem and I
              just can't solve it. I've really got Problems with debugging seam apps.
              If I could debug it step by step, I bet I could see, where the bijecting mechanism fails. But all I do is deploying and redoplying ear files to the
              server, reading obscure stacktraces, fiddeling around with some code lines, redeploy again, and check for new stack traces.
              I'm feeling so slow doing this process.

              Thank you very much for your help.


              • 4. Re: Using @DataModel and @DataModelSelection in different Se
                pmuir

                No,you would need to call a method on the bean for the bijection to work. You could use a factory for this...

                The exception means that the value of #{e.rowData} is null - required=false will allow null values. For some reason the value is not being set - you'll have to see why.