1 2 Previous Next 15 Replies Latest reply on Feb 25, 2010 12:38 PM by maggi maggi

    seam-gen on single table

    maggi maggi Newbie

      I have created EJBs and forms using Seam Generate Entities after adding tables in database. But I forgot to add one table phone. I wish to create the ejbs and forms just like other's using seam-gen again without deleting the current project.


      Can I run seam-gen on single table?

        • 1. Re: seam-gen on single table
          Samuel Doyle Apprentice

          Look at the seam-gen.reveng.xml in your generated projects directory I believe it provides a commented out section telling you how to do just that.

          • 2. Re: seam-gen on single table
            Samuel Doyle Apprentice

            I meant to say generated projects resource directory

            • 3. Re: seam-gen on single table
              Sergio Samayoa Newbie

              I think that what san d needs is the hability to generate Home and Query components and views for one table / entity only without the need of generate of whole application.
              I wish also that seam-gen could do that.


              Regards.

              • 4. Re: seam-gen on single table
                maggi maggi Newbie
                Sergio, you are right.

                Samuel,

                I think I should use following two lines in the seam-gen-reveng.xml, by replacing TABLENAME with actual table name. Is that good enough?

                   <table-filter match-name="*.*" exclude="true"/> 
                   <table-filter match-name="TABLENAME" exclude="false"/>

                Regards,
                San
                • 5. Re: seam-gen on single table
                  Samuel Doyle Apprentice

                  Why not just create another skeleton project and generate whatever you need within it and copy only the pieces you need over into your new project?

                  • 6. Re: seam-gen on single table
                    maggi maggi Newbie
                    Yes. I did that many times. I needed this solution.

                    Hey do you have any idea how to pass "<" from EJB to xhtml? It is considering &lt; instead of "<". Actually I wish to pass a html table tag from session bean to xhtml.

                    Also I am trying to find a solution to execute a query which picks up a data from two tables and displays the result on the xhtml page. Please send some example, if you have. Guide whether to use entitymanager em or EJBQL.

                    Please send me a sample how the ejbql needs to be configured and returns resultset to populate on xhtml
                    • 7. Re: seam-gen on single table
                      Samuel Doyle Apprentice

                      Various JSF output tags have an escape attribute which defaults to true, you probably want that set to false.


                      You would have to be a bit more detailed on what you are trying to accomplish for the second part. Are you trying to use a datatable? Look at the datatable and repeat components for RichFaces on their demo site as well as the other iterators.
                      http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?c=dataTable&tab=usage

                      • 8. Re: seam-gen on single table
                        maggi maggi Newbie
                        1) JSF output tags - how to set it to false? I am bit new to this. If I type <table><tr><td>Seam framework<td><tr> in xhtml, it displays "Seam framework" on browser in a table. Now instead of typing in xhtml, I am passing a string from EJB and reading it on xhtml. It displays the entire table tag with &lt; etc as is, instead of actual table with "Seam framework" text in it. How do I achieve this?

                        2)The example you provided is good for frontend. I am actually looking out solution for backend, that is EJB, interface etc. My query is something like this:
                        SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order
                        FROM customers cust,
                            stores store,
                            locations loc,
                            store_customers sc,
                            product prod
                        WHERE prod.name = 'widget'
                            AND store.loc_id = loc.id
                            AND loc.name IN ( 'Melbourne', 'Sydney' )
                            AND sc.store_id = store.id
                            AND sc.cust_id = cust.id
                            AND prod.id = ALL(
                                SELECT item.prod_id
                                FROM line_items item, orders o
                                WHERE item.order_id = o.id
                                    AND cust.current_order = o.id
                            )

                        I have entities created for customer, store etc. Looking out for an EJB, which is executing these kind of queries and passing data to xhtml to render just like the URL that you sent.

                        Please help me. Thanks.
                        • 9. Re: seam-gen on single table
                          maggi maggi Newbie
                          just to clarify more (correction) my SELECT query first statement is

                          SELECT cust.name, cust.address, cust.phone, cust.id, cust.current_order, stores.heading

                          That means, I wish to display stores as well as customer field names.
                          ------------------------------------------------
                          I have set this query to String EJBQL

                          Now how to get results as per above select as I have two objects in the List. please suggest the method details in EJB including constructor if any changes in it.
                          • 10. Re: seam-gen on single table
                            maggi maggi Newbie
                            Regarding 1) xhtml problem:

                            - In side EJB, refer following method where I am setting the variable

                            public String getResult() {
                                        resultSt = "<table class=\"mytable\"><tr><td>Seam Framework</td></tr></table>";
                            }

                            - Now in xhtml I am displaying the variable as follows:
                            <hr/> #{myHome.resultSt}
                            <hr/>

                            - In the browser, I get following displayed:
                            <table class="mytable"><tr><td>Seam Framework</td></tr></table>

                            - When done View source in browser, I get following:

                            <hr /> &lt;table class=&quot;mytable&quot;&gt;&lt;tr&gt;&lt;td&gt;Seam Framework&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

                            - I just want that view source should display "<" instead of &lt; etc so that the table can be rendered in browser. How do we do it?
                            • 11. Re: seam-gen on single table
                              Samuel Doyle Apprentice
                              <h:outputText value="#{somevalue}" escape="false"/> Although you shouldn't probably be doing this


                              From your query it looks as if your entities would have a jointable store_customers defining a @OneToMany between your
                              Store and Customer:

                              This isn't the answer you are looking for but to give you an idea.
                              List<Store> stores = entityManager.createQuery("
                                 select store from Store store where store.location.name in ( 'Melbourne', 'Sydney')
                                 join store.customer cust
                                 where cust.order in ( :listOfOrders ) // where list of orders is whatever you come up with.
                              ").getResultList()
                              You construct queries using . path navigation as you would in jsf

                              You then have a list of Store(s) from which you can then iterate across the list of customers such as store.getCustomers() or whatever.

                              The property names such as entity classname and attributes are case senstive and need to match.

                              Hope this helps
                              • 12. Re: seam-gen on single table
                                maggi maggi Newbie

                                Do you have any example to refer? any link


                                Also I am using String EJBQL and setting using setEjbql(EJBQL) in the constructor. how do i get resultlist?

                                • 13. Re: seam-gen on single table
                                  maggi maggi Newbie
                                  The list will have stores as well as customers. How do we consider <LIST>Store....?
                                  • 14. Re: seam-gen on single table
                                    maggi maggi Newbie

                                    One more quick question.


                                    Can seam-gen create jsp just like it creates the xhtml form quickly seam new-form?

                                    1 2 Previous Next