6 Replies Latest reply on Feb 21, 2006 11:34 AM by Stefan Liebner

    DataModel outjection and navigation problem

    Stefan Liebner Newbie

      Hi all,

      I have a problem using the DataModel Annotation.
      (JB4.0.4RC1 + Seam Beta2)

      I have a Facelets/XHTML/JSF Page (P1) which calls a SFSB Seam (B1)Component Action/Method. That method hands over some data to another SFSB (B2) which got injected into the first SFSB via @In(create=true) and returns an outcome that leads to a second JSF Page (P2).

      The second page (P2) is partially rendered correctly, but all Data from that Bean (B2), that is not directly accesible via a getter Method cannot be found.

      There are three DataModels in B2 (e.g. @DataModel(value="xyz")) which are not accessible. I get the following message in the server log:

      DEBUG [org.jboss.seam.jsf.SeamVariableResolver] resolving name: xyz
      DEBUG [org.jboss.seam.Component] seam component not found: xyz
      


      Why? When is the DataModel outjected? What triggers it?

      I see that there is a SLSB in the reverse engineering tool code which gets data from a FinderBean and adds it to the EditorBean. That is basically the same that I want to do, but do I really need that third bean? Less Code, (sometimes) less trouble.

      Greetings,
      Stefan

        • 1. Re: DataModel outjection and navigation problem
          Stefan Liebner Newbie

          Hi all,

          quick addition:

          I tried delegating the request handling to a SLSB like in the generated examples (copied a selector and removed some methods). Same result.

          My jsf page expects the DataModel to be named "yxz" like mentioned above.

          Any ideas?

          Greetings,
          Stefan

          • 2. Re: DataModel outjection and navigation problem
            Gavin King Master

            A DataModel is outjected when either:

            * An action method of the component is called
            * You have an @Factory method defined

            Probably you can fix your problem by adding an @Factory method.

            Also check the scope of the @DataModel, esp. if you are using an SLSB.

            • 3. Re: DataModel outjection and navigation problem
              Stefan Liebner Newbie

              Hi Gavin,

              I tried

              @Factory(value="xyzList")
              @DataModel(value="xyzList")
              public List<xyz> getXyzList() {
               ...
              }
              


              That raises an exception

              java.lang.IllegalArgumentException: create method not found
              ...
              Caused by: java.lang.NoSuchMethodException: $Proxy414.getXyzList()
               at java.lang.Class.getMethod(Class.java:1581)
               at org.jboss.seam.Component.callComponentMethod(Component.java:1116)
               ... 40 more
              


              I also tried the PAGE scope for the DataModel. No change.

              Well, if I understand the outjection invocation algorithm correctly, I have to call Bean B2 from my example and have B1 injected into B2 to get the data from B1.

              I'll give it a try.

              Thanks so far,
              Stefan

              • 4. Re: DataModel outjection and navigation problem
                Stefan Liebner Newbie

                Hi Gavin,

                when I invoke Bean B2 from the JSF Page and pull the state from B1 everything works fine.

                The first Page P1 was rendered using data from B1. Than the request adresses B2 which is rendered by P2.

                Is it for granted, that I always get B1 in B2?

                B1 is the Finder with Session Scope and B2 is Conversation Scope.

                OK, works for now, have to shift some code around :-)

                Thanks a lot,
                Stefan

                • 5. Re: DataModel outjection and navigation problem
                  Gavin King Master

                   

                  "liebner" wrote:
                  Hi Gavin,

                  I tried

                  @Factory(value="xyzList")
                  @DataModel(value="xyzList")
                  public List<xyz> getXyzList() {
                   ...
                  }
                  


                  That raises an exception

                  java.lang.IllegalArgumentException: create method not found
                  ...
                  Caused by: java.lang.NoSuchMethodException: $Proxy414.getXyzList()
                   at java.lang.Class.getMethod(Class.java:1581)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:1116)
                   ... 40 more
                  




                  Because you forgot to add getXyzList() to the local interface.

                  • 6. Re: DataModel outjection and navigation problem
                    Stefan Liebner Newbie

                    Hi Gavin,

                    you're right.

                    Works fine now.

                    To clarify your remark with the factory annotation:
                    -It is enough to have one @Factory annotation per EJB to get all DataModels outjected.
                    -The Method annotated like that is currently called first. I use that method to refresh an EntityBean for all other DataModels.

                    Thanks a lot again,
                    Stefan