1 2 Previous Next 22 Replies Latest reply on Feb 19, 2007 9:51 PM by seto Go to original post
      • 15. Re: Who uses EntityHome objects?
        gavin.king

         

        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.


        huh, why do you say that? use

        • 16. Re: Who uses EntityHome objects?
          baz

          hi gavin,
          what was the rest of your posting?

          • 17. Re: Who uses EntityHome objects?
            baz

            Finally i got it.

            <pages>
             <page view-id="/search.xhtml">
             <param name="accountId" value="#{accountHome.id}" converterId="javax.faces.Long" />
             </page>
            </pages>
            

            This means that the value of the accountId parameter will be set to the Id of accountHome. This part was not obvious to me.:-(
            And The value of the accountHome id will be remembered in the parameter. This comes out very clearly from the docs.
            Ciao,
            Carsten

            • 18. Re: Who uses EntityHome objects?
              bulloncito

              I'm having the same problem, I'm starting with seam, using EntityHome, and as far as I understand that only propagates the parameter to the page, still has to be injected, I use

              @RequestParameter Long userId ;

              however my source is nearly identical to the one in the exaples of reference documentation (started from seam-hotel-booking and extended it) and form always shows "Create" buttons, id is not being propagated, or EntityHome is not properly configured, I'm lost. I cannot update/delete wich was the main reason on using EntityHome. If I actually pess submit button to new #{userHome.persist} I get the following:
              java.lang.IllegalStateException: No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)

              Apparently some validation assigned null variables where @NotNull fields were.
              ... is there any working EntityHome example ? searched examples dir for "EntityHome" and no strings were found.


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

                For a working example, see examples/contactlist, or simply generate an application using "seam setup new-project generate-entities".

                • 20. Home Entity not partially working
                  bulloncito

                  ... finally managed to use EntitiHome in my project, however this code works:

                  <factory name="user"
                   value="#{userHome.instance}"/>
                  
                  <framework:entity-home name="userHome"
                   entity-class="myPackage.User"
                   entity-manager="#{entityManager}" />


                  while this one does not:

                  @Name("userHome")
                  @Scope(ScopeType.CONVERSATION)
                  public class UserHome extends EntityHome<User> {
                  
                   @In EntityManager entityManager ;
                  
                   @RequestParameter Long userId ;
                  
                   @Factory("user")
                   public User initUser() { return getInstance() ; }
                  
                   @End
                   public String persist() {
                   super.persist() ;
                   return "users" ;
                   }
                  
                   @End
                   public String update() {
                   setId( userId ) ;
                   super.update() ;
                   return "users" ;
                   }
                  
                   @End
                   public String remove() {
                   setId( userId ) ;
                   super.remove() ;
                   return "users" ;
                   }
                  
                   @Destroy @Remove
                   public void destroy() {}
                  
                  }


                  ... is this a bug ? or am I missing something ? I believe it's better to use inheritance to add some extra features by hand, but I can't :(

                  • 21. Home Entity not Working
                    bulloncito

                    ... finally managed to use EntitiHome in my project, however this code works:

                    <factory name="user"
                     value="#{userHome.instance}"/>
                    
                    <framework:entity-home name="userHome"
                     entity-class="myPackage.User"
                     entity-manager="#{entityManager}" />


                    while this one does not:

                    @Name("userHome")
                    @Scope(ScopeType.CONVERSATION)
                    public class UserHome extends EntityHome<User> {
                    
                     @In EntityManager entityManager ;
                    
                     @RequestParameter Long userId ;
                    
                     @Factory("user")
                     public User initUser() { return getInstance() ; }
                    
                     @End
                     public String persist() {
                     super.persist() ;
                     return "users" ;
                     }
                    
                     @End
                     public String update() {
                     setId( userId ) ;
                     super.update() ;
                     return "users" ;
                     }
                    
                     @End
                     public String remove() {
                     setId( userId ) ;
                     super.remove() ;
                     return "users" ;
                     }
                    
                     @Destroy @Remove
                     public void destroy() {}
                    
                    }


                    ... everything else is the same.

                    ... is this a bug ? or am I missing something ? I believe it's better to use inheritance to add some extra features by hand, but I can't :(

                    • 22. Re: Who uses EntityHome objects?
                      seto

                      From the documents, you can see that the right way is to override the getId(). But it isn't correct to setId for the update() or remove()

                      1 2 Previous Next