6 Replies Latest reply on Aug 22, 2007 10:34 AM by -arthur-

    The zen of seamgen'd Home/EntityHome

    tynor

      At the risk of being accused of not sufficiently using the source Luke, can someone explain how seamgen'd EntityHome's are intended to work?

      Our project was bootstrapped with seamgen, but has taken on a life of its own. As we add new Entities, we need to add corresponding EntityHome's, but there are many things about the seamgen'd ones that are not obvious to us. Cutting/pasting blindly can be a dangerous thing, so we wish to understand why seamgen did what it did. To start:

      * When will a getDefinedInstance() ever return non-null? I've never seen any of our wire() functions set any properties from a non-null getDefinedInstance() call.

      * How are the various @In FooHome's that are refered expected to be initialized? When should we be calling their setId() functions (which seems to be the trigger for making getDefinedInstance() return non-null)

      * What are the expectations from pages.xml to call wire()? What about when instantiating a class programatically? (ie. if I add a MyEntity findByName() function, should I be calling wire() and various setId() functions?


      The only discussion I can find that explains some of this is the following, and it only says "what" is happening with respect to xxx-to-one properties, not why:

      http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047589

      There are no comments on the Home / EntityHome classes that the seamgen'd classes use - perhaps once some of these questions are answered I can help write some.


      Seam 1.2.1-GA
      (though I've checked Seam 2.0.0-beta and don't see any docs for this there either).

        • 1. Re: The zen of seamgen'd Home/EntityHome
          tynor

          I think we've worked some of this out. (correct me if I'm wrong!)

          The getDefinedInstance() functions on the homes will never be set unless the page is called with an <s:link><f:param> corresponding to one of the 's in the FooEdit.page.xml -- those params will in turn call through EL to the various home objects, indirectly calling setId() which causes getDefinedInstance() to return a non-null object. Presumably, this is intended as a way to instantiate a new object with non-null values for these fields. (Gavin's post implies that its a way to pre-instantiate non-null foreign key fields so that they are not null at persist time).

          However, because wire() is called for both newly created and read-from-database (managed) objects, setting those params can overwrite field values read from the db - (that doesn't seem to be something one would want to do very often - perhaps its just a side effect of the implementation not intended to every really be used).

          Also, it's not clear why only xxx-to-one fields get this treatment - why not have support for setting String, int, etc. fields too?

          We have customized some of our Home class createInstance() functions to set various default values for certain fields. It would be instructive to know when Seam developers would instead advise initializing these variables in wire() instead?

          NOTE to Seam developers: it would be very helpful if you could add an example in a future seam release that uses and extends seam-gen generated EntityHomes and views as a way to document how they are intended to be used (in addition to adding some Javadoc to the Home and EntityHome classes :)). Currently, each of the examples uses a different approach to DAO/Home interface, and none of the examples use these seamgen home beans, so it's hard to see what the seamgen framework's intent is.

          • 2. Re: The zen of seamgen'd Home/EntityHome
            • 3. Re: The zen of seamgen'd Home/EntityHome
              pmuir

              Please create a JIRA issue for some docs on how to use a seam-gen'd app, and another for more javadoc for Seam framework classes

              • 4. Re: The zen of seamgen'd Home/EntityHome
                -arthur-

                There should (no, actually have to) be JavaDoc in the Framework Classes.
                EntityHome is one of the first Seam classes the User gets in touch and nobody knows how to use them, or how they are intended to be used.

                Thats almost frustrating for users which start using seam.
                (like me in the beginning)

                This is half of a day of work and could help a really huge amount of people out there.

                • 5. Re: The zen of seamgen'd Home/EntityHome
                  tynor
                  • 6. Re: The zen of seamgen'd Home/EntityHome
                    -arthur-

                    Thanks for posting this topic on jira.
                    I've voted for both issues.