1 2 Previous Next 22 Replies Latest reply on Feb 19, 2007 9:51 PM by seto

    Who uses EntityHome objects?

    smokingapipe

      I'm just now reading through Chapter 14 and they have a lot of discussion of using EntityHome objects. These can be used either by extending EntityHome, or even more easily by adding a few lines to components.xml. These objects handle the basics of creating and updating and finding entities.

      I haven't used these at all so far. Instead I have created simple SFSBs to do all this.

      I'm just wondering, do people use the EntityHome objects in components.xml for most of the grunt work? Is this an easy way to go for this? Should I start using them?

        • 1. Re: Who uses EntityHome objects?

          Most of the examples were written before EntityHome came into existence. I know I used it in seam-pay. There I subclassed EntityHome to add some custom persistence logic and make use of the @RequestParameter. I also configured some of the attributes in components.xml.

          I think for non-trivial projects you will tend to have at least SOME custom logic and would want a subclass, but with Seam there's no need to do that until you are ready. Configure it in XML and when you need something more, you can add the subclass without anything else changing.

          • 2. Re: Who uses EntityHome objects?
            baz

            Hello,
            Yes i use them. But only the Hibernate form.

            For Seam 1.5.0 the application framework is described in chapter 10.

            I was using them till the early beginning. The framework went to heavy refactoring but it was usefull for me to follow. Now i am refactoring the code to use the full power of the framework.
            Ciao,
            Carsten

            • 3. Re: Who uses EntityHome objects?
              smokingapipe

              Ok, I was just wondering because they weren't really prevelant in the examples. I may start trying them out.

              • 4. Re: Who uses EntityHome objects?
                baz

                Hello
                (3 questions at the body, please take a look)
                I am interested if you are able to run any example with entityHome objects. For me, the examples do not work (seam-pay,ui etc)
                ---------
                Could it be that i missunterstand the conzept?
                So far i have used entityHome objects this way:

                 <factory name="bazExperiment" value="#{bazExperimentHome.instance}"/>
                
                 <component name="bazExperimentHome" class="org.jboss.seam.framework.HibernateEntityHome">
                 <property name="entityClass">de.bafz.lims.model.Experiment</property>
                 <property name="session">#{bazDatabase}</property>
                 <property name="id">#{bazExperimentID}</property>
                 </component>
                

                When i set the bazExperimentID in any context, i will have the object bazExperiment managed. That is all i want to do, so far.

                But with the namespace concept i am not able to configure the id. The framework-1.1.xsd does not allow to configure an Id:-(

                Is the Id is now implicit?
                What is the recommended way to set the Id?
                Has anybody succeded in running the examples with entity Home objects?

                I am using seam 1.5.0GA for now
                Ciao,
                Carsten

                • 5. Re: Who uses EntityHome objects?
                  pmuir

                  As Norman says, the applicaiton framework is just newer :) I use it extensively, and mix and match between components.xml and extension when needed.

                  Baz - I use pages.xml to set the id - as described in the docs I believe.

                  • 6. Re: Who uses EntityHome objects?
                    baz

                    I have reread the docs (chapter 10 for seam 1.1.5GA) many times.
                    My objects are never created because i do not know how to specify the ID.
                    If i use the old method (without namespaces) all is well.

                    @petermuir
                    To which paragraph in the docs do you reference?
                    What i like to do is described by you here:
                    http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamEntityHomeForLongRunningContexts
                    Is this possible only with components.xml and namespaces?

                    When i rewrite my example with namespaces it looks like:

                     <factory name="bazExperiment" value="#{bazExperimentHome.instance}"/>
                     <framework:hibernate-entity-home name="bazExperimentHome"
                     entity-class="de.bafz.lims.model.Experiment"
                     session="#{bazDatabase}"/>
                    

                    I am not able to specify any Id in this case. Forbidden by the schema.
                    Which is the id of bazExperimentHome in this case?
                    With the configuration from above (earlier message) i can expose bazExperimentID into session context and get the same behaviour as you described in the wiki?

                    What will be the correct way to select an experiment?
                    By now i expose bazExperimentID with the selected experimentid to session scope. Is this the right way to do it?

                    Is it possible, that the schema definition has an error. Since, in the doc there is an paragraph, right to the beginning of chapter 10,
                    where the id is set.
                    But in practice, this results in an error.
                    Ciao,
                    Carsten

                    • 7. Re: Who uses EntityHome objects?
                      pmuir

                       

                      Now, if we want to be able to display, update and delete pre-existing Person entries in the database, we need to be able to pass the entry identifier to the PersonHome. Page parameters are a great way to do that:

                      <pages>
                      <page viewid="/editPerson.jsp">
                      <param name="personId" value="#{personHome.id}"/>
                      </page>
                      </pages>


                      - that was the bit I was talking about. I don't think you can achieve what I wrote in the wiki easily using components.xml and not extension

                      • 8. Re: Who uses EntityHome objects?
                        baz

                         

                        to pass the entry identifier to the PersonHome

                        But than the example reads like:
                        <pages>
                         <page viewid="/editPerson.jsp">
                         <param name="personId" value="#{personHome.id}"/>
                         </page>
                        </pages>

                        If i understand it correctly, the personHome.id will be passed, not the entry identifier. And i do not see any further reference to personID in the doc.

                        For me it seems helpful when i could look at the existing example used in the documentation. This bit is certanly very unclear to me,by now.
                        Ciao,
                        Carsten
                        PS: with the posted components.xml snippet (without Namespaces) my application behaves like described in the wiki.

                        • 9. Re: Who uses EntityHome objects?

                          Sorry for jumping back in the middle here, but can you explain exactly the problem you are having with the namespaced XML?

                          • 10. Re: Who uses EntityHome objects?
                            sjmenden

                            I use the EntityHome exclusively and I can't live without it. It significantely reduced my code and made everything much more maintainable. I do have a lot of customer logic in my Class that extends EntityHome, but this is expected. The main point is, I get full CRUD from one class and one xhtml page.

                            • 11. Re: Who uses EntityHome objects?
                              smokingapipe

                              I'm going to start using them. Most of the grunt work is the same all over the place so it would be cool if I can get it all from one class.

                              • 12. Re: Who uses EntityHome objects?
                                guanwh

                                if i understand correctly there are two ways to set request parameter
                                1.annotation @RequestParameter
                                2. using page parameter in pages.xml

                                • 13. Re: Who uses EntityHome objects?
                                  gavin.king

                                  Page parameters are now definitely the preferred approach. For example, the redirect-to-login-and-then-redirect-back stuff depends upon page params.

                                  • 14. Re: Who uses EntityHome objects?
                                    baz

                                    Now i am really confused.
                                    For me this is true

                                    @RequestParameter in a java class says that something is injected that is a Parameter. It never pass a parameter.

                                    page parameter in pages.xml specify that a paramter should be passed.
                                    So for me, they must be used in conjunction

                                    To gavin: where is my error?

                                    @norman My problem is to specify the id of an object. But i have realized, that the possibility to set the id in components.xml is no more there. With or without namespaces. For now i use extension to define the name of the id. Is there a possibility that there is a default name (eg for PersonHome the id will be named personHomeId)?

                                    1 2 Previous Next