1 2 Previous Next 18 Replies Latest reply on Feb 15, 2009 12:01 AM by waltc Go to original post
      • 15. Re: PersistenceException
        waltc

        What I find most frustrating about this is answering these questions, and they are really good questions, makes me feel like I am not sure what I am talking about...which I am not. I doubt anyone likes that reality thrown in their face, much less when it's down in a masochistic manner. I'd be ecstatic if I got to the point where I really understood Seam.


        On your question of @PersistenceContext vs @in EntityManager I believe it's the later but I am not sure. So far all I've been trying to do is getting the fracking seam-gen CRUD application working based on a pre-existing group of tables under MySQL. So I see Hibernate is constantly adding indexes and foreignkey constraints even when they are already defined. This isn't an AS 5 issue, it's a Hibernate issue. I specified validate in the hbm2ddl.auto yet what's in the project is update. Don't ask me how that happened, that is a Seam issue or a Walt Corey issue. Probably the later. From what the Don Allen book says is you do the @PersistenceContext or @EntityManager (preferred) in actions. Since this is all whizbang pixie-dust development so far I haven't probed deeply enough to figure out the seam piece that issues the @EntityManager annotation.


        With the JBoss AS 5 vs. AS 4.x, Allen really never mentions the host except to say not Tomcat and AS 5 is EE compliant and he really likes GlassFish.  From what I have described have I mentioned anything that might point to why this needs to be an ear, not a war file?


        Walt

        • 16. Re: PersistenceException
          waltc

          Hi,
             Apologies that this is off topic but you've been really good at answering (thank you!) and I have another problem that I am sure is a quick answer from you. I've actually made a lot of progress in this journey I've been on this last month. Each app I do builds on what I did in the previous, so I am trying to take small steps. I did write an app that was essentially a seam-gen crud but I added an additional action if one of the attributes of that row matched the correct state. Here is that code in the xhtml:



                      <s:link action="#{Resubmitter.resubmit()}"
                             value="Resubmit"
                       propagation="none"
                       id="upddocumentResubmit"
                       rendered="#{!Resubmitter.isValid()}">
                          <f:param name="upddocumentUpdDocumentDocId"
                                  value="#{_upddocument.updDocumentDocId}"/>
                      </s:link>
          


          Here is the action method:



              public boolean isValid() {
                   boolean ret = true;
                   Upddocument upddocument = upddocumentHome.getInstance();
                   if (upddocument != null) {
                        Integer state = upddocument.getUpdDocumentDocState();
                        if (state != null && state == errorState) {
                             ret = false;
                        }
                   }
                   return ret;
              }
          


          This worked. I am not real clear why upddocumentHome had the current selected row. This is the crux of my current issue. I the current app I havem instead of an action, a column that has a value depending on some extra processing. Here is the xhtml snippet for that.



                  <h:column>
                       <f:facet name="header">
                           <h:outputText value="rsrvTo" />
                      </f:facet>
                      <h:outputText value="#{reserve.isReserved() ?  userHome.instance.name : 'available'}"/>
                      <f:param name="serverHome" value="_server"/>
                  </h:column>
          


          Note: this is different than the first example due to trial and error. In the first example xxxHome was magically populated with the current row, making everything very easy. That wasn't working here so I was trying different things to achieve the same results. )server is the current row (var=_server). Here is the action method.


               public boolean isReserved() {
                    Date now = new Date();
                    boolean result = false;
          //          Server server = serverList.getDataModelSelection();
                    Server server = serverHome.getInstance();
                    Set<Reservation> set = server.getReservations();
                    for (Reservation reservation : set) {
                         if (reservation.getFromDate().before(now) && reservation.getToDate().after(now)) {
                              result = true;
                              userHome.setId(reservation.getUser().getId());
                              userHome.getInstance();
                              break;
                         }
                    }
                    return result;
               }
          


          Note: the commented out line didn't work either but I did have an app where that worked flawlessly. So basically an instance of server can have reservations against it. If one of the reservations is currently active then the server is reserved. If all of the reservations are either expired or future then the server is not reserved. If it is reserved I want to populate the userHome with the current user holding the reservation. I do this as there may be more than one reservation but only one active and I want to return the boolean to instruct the EL to either display 'available' or the name of who has it reserved. This method gets executed for every single row but the server object appears to never get populated and the set is present but always empty even though on one of the servers if I 'view' it I see the active reservation against it.


          What am I missing?


          As always I appreciate you time in helping in the journey to master Seam.
          Thanks,


          Walt

          • 17. Re: PersistenceException
            waltc

            Hi Bob,
               I wanted to get back to you from our earlier discussion. Since the first of January I've successfully built several seam apps, perhaps semi successfully as each has been nerve wracking. I think, could be wrong but I think, the largest difference between what Dan talks about in his book and today's GA releases has been his book. Specifically, Dan spent a lot of time with mods to component.xml. In some cases he points out you could do it with annotations but in others I get a sense it has to be in component.xml. The apps that seam-gen creates put virtually nothing in in component.xml. I wonder if a new edition is in the works that covers seam 2.1.x or 2.2, if that is in the later stages of development? I do agree with your comment on hot deploy, I think it does something, or rather something happens, over time where jboss takes forever to start up.  I had a problem over the weekend where I couldn't get a field from the form into the action method. It was very frustrating and finally, with some help, I discovered the text field wasn't getting submitted. Ironically, Dan did cover it in his book but when I read it the subtlety didn't register that s:button did the same thing as h:commandButton.....except submit text fields. The point I am going after is whether this journey is going to be festooned little or big land minds of subtleties that are either called out in his book or left for the reader to find. With each victory I feel a little better about this journey but just prior to the next 'victory' I question the worthiness of of the venture. Didn't Dan even hint at that with a reference to magic pixie-dust?


            Are you still pursuing Seam or did you end with the completion of your last app?


            Walt  

            • 18. Re: PersistenceException
              waltc
              For those of you who happen on this sub-thread the answer was, or appears to be...


              `   <begin-conversation join="true" flush-mode="MANUAL"/>

                 <action execute"=#{serverHome.wire}"/>
                 <action execute="#{reservationHome.wire}"/>

              `
              in the xxx.page.xml file corresponding to the xxx.xhtml

              What I did notice was, in action columns in the files generated by seam-gen...


              `                <f:param name="serverId"
                                      value="#{_server.id}"/>
              `

              where _server, in this case, is from the current pointer in the resultsList from the xxxList component. I believe this primes the xxxHome component such that the wire() action will populate the full instance such that it can be accessed by field.

              What I could not understand was in the stock crud applications that seam-gen spits out selecting a row in the xxxList page would bring up the proper item at row selected in the edit or display page without any intervening backing bean action.

              Walt
              1 2 Previous Next