12 Replies Latest reply on May 9, 2007 12:47 PM by carlos.abreu

    CRUD screen


      Hello everyone, i searched on the SEAM examples, a example of screen that uses the CRUD model. But i can´t find it... Can anyone tell me if there is an example of that ?



        • 1. Re: CRUD screen

          If you are talking about CRUD using the Seam Framework (EntityHome and all that) then I believe the contact list example uses that particular method of crud.

          If you are talking about writing your own set of CRUD pages, then there are a number of ways to do it.

          In the Issues example - inject the issueFinder bean into the issueEdit bean and get the selected item from the issueFinder. (seems messy to me)

          - or -

          Use bijection to outject the selected item, and inject it into the edit bean

          - or -

          Use request parameters to pass the ID of the object to be edited to the editor page (best option for RESTful URLs) . The Seam blog uses this method.

          - or -

          Use EL Enhancements to pass the object from the list page to the edit bean from within the datatable : i.e.

           <s:link value="Edit" action="#{personEditBean.editPerson(person)/>

          where "person" is the var value in your datatable. You can see this type of example in the hotel booking app with the "selectHotel(hot)" function in the hotel listing page. It starts the booking conversation and passes the hotel in using the "hot" variable from the datatable.

          • 2. Re: CRUD screen

            Hy Delphi, i take a look on the issues tracker application... It´s basically what i need, but the example seems to be buged....

            Call you tell me, how can i do for set the form on the screen with the data that i select ? Do i need a hidden field to hold the ID of my register ?


            • 3. Re: CRUD screen

              I think what you should do is neither of the above, but generate a new application skeleton with seam-gen. It's very well documented. Then generate a single entity, which will also produce a CRUD screen. This is the smallest and most consistent example of CRUD functionality with Seam you will find.

              • 4. Re: CRUD screen

                If you mean an all-on-one-page CRUD, I'm doing this using a Seam Gen'd application and using the EntityHome objects.

                On the left of the screen is my input form. No real difference to the ones created by Seam Gen but the page.xml returns the view to itself. On the right is the DataTable. This has a column with links for Edit and Delete as per below:

                 <f:facet name="header">Action</f:facet>
                 <s:link action="#{objectHome.find}"
                 title="Click here to edit this record">
                 <f:param name="objectId" value="#{tableVar.objectId}"/>
                 <h:graphicImage url="/img/edit.png" border="0"/>
                 <s:link action="#{objectHome.remove}"
                 onclick="return confirm('Are you sure you want to delete this row?');"
                 title="Click here to delete this record">
                 <f:param name="objectId" value="#{tableVar.objectId}"/>
                 <h:graphicImage url="/img/cross.png" border="0"/>

                The page.xml has the param like this:
                <param name="objectId" value="#{objectHome.objectId}"/>

                And in the objectHome after an Update or Persist I remove it from the all contexts:

                This is working quite well for me at the moment, but the downside is that it exposes the IDs. Would welcome any improvements.



                • 5. Re: CRUD screen

                  Hy Christian, i tried to do what u tell me... But i don't see a CRUD page generated by seam-gen...

                  Perhaps i looked the wrong page(http://docs.jboss.com/seam/1.1BETA2/reference/en/html/gettingstarted.html) of seam-gem ??



                  • 6. Re: CRUD screen

                    Hy everyone,

                    Damian, defined very well what i want to do on the CRUD page "all-on-one-page"....

                    My principal objective, is to have my Actions Session Beans in a pattern. Because almost 90% of the screens of my application, will have the same behaviors...

                    With the Help of Christian an Delphi i created the structure of my application in a very elegant way...

                    Therefore, the only behavior that is missing for my Actions is the edition of the entities data.

                    So my question is in the html form in the CRUD page... Can u tell me, how can i set the fields in the form with the data that i select in the data table ?

                    I don't know if i am expressing clearly, please let me know....

                    I can sent the source code by e-mail if anyone interested...



                    • 7. Re: CRUD screen

                      As the input fields in the input form are based on the objectHome (EntityHome) they will be populated when the page reloads when you click on the edit link in the dataTable. This is done via the 2way param from the page.xml.

                      So if you input form has inputs like:

                      <h:inputText id="name" value="#{objectHome.instance.name}"/>

                      Then it will be populated by the objectHome.find() method using the objectId.

                      • 8. Re: CRUD screen

                        Damian, this looks interesting.... Can you send me an example of that to my e-mail (interativa_soft@yahoo.com) ?

                        I would like to know if there is a way to do that without using the pages.xml.... I wanna to avoid the use of xml configuration files...


                        • 9. Re: CRUD screen

                          I'm not sure how you'd do this without xml configuration. It's really quite minimal configuration.

                          Maybe you should look at some of the suggestion's made by Delphi earlier? I haven't tried any of them aside from the way that I've outlined.

                          • 10. Re: CRUD screen

                            Well i looked the examples that Delphi told me, but i don´t see how the examples can help me with my CRUD page.

                            I think that what you tell me is the best choice, can you send to me a simple example of your CRUD page ?

                            • 11. Re: CRUD screen

                              Tried to send you some examples but Yahoo thinks that you don't exist. Re-post your email address and I'll resend it.

                              • 12. Re: CRUD screen

                                Humm... that is strange, try send to interativa_soft@yahoo.com.br or carlos.abreu@gmail.com...