2 Replies Latest reply on May 18, 2009 8:05 AM by Varun Chopra

    Jboss Seam - Confusion on Project Structure

    Varun Chopra Newbie

      I used Jboss tools within eclipse to create a new Seam Web Project. When it was done, it created following 4 folders:


      myproject
      myproject-ear
      myproject-ejb
      myproject-test



      I got them all directly under workspace without a common parent folder. There was no build.xml. But it was already deployed and I was able to republish it after making changes. It also picked my changes to xhtml files directly without redeploy.


      On the other hand, one of my teammate created new project from database using seamgen. The structure seamgen generated is more compatible with standard j2ee projects structure. There is a common parent folder 'myproject'. myproject has a build file, src, dest, lib, view etc. folders. He's able to use ant script file to build and deploy code. But his changes to .xhtml files are not picked by itself. My questions are:


      1. Why in first case it generated a scattered structure with no common folder and why does it not match standard j2ee structure, why there is no build file?
      2. How can I make it autodeploy changes to xhtml files in second case?
      3. In second case, it also generated view, entity and session beans for each database table. Now if I add a new column to a database table (only one table), how can I update code only for that table in whole project? When I searched references to java entity class for that table, it shows 65 matches in project. Am I supposed to make this change manually at 65 places or is there a better way to update code?


      Hoping for quick reply


      Thanks in advance

        • 1. Re: Jboss Seam - Confusion on Project Structure
          Arbi Sookazian Master

          I prefer the one root folder (project folder) approach via seam-gen cmd line.


          Here is some feedback I got on this very confusing topic from the JBoss Tools team:


          me:




          Also, it seems strange to me that when you use seam-gen from cmd line, you end up with one high level project folder (in my case 'BETS'). But when you create a new Seam project using JBoss Tools (or Seam tools??), you end up with 4 high level folders for the exact same project (i.e. it's an EAR, etc.)


          JBoss tools team:




          Seam-gen projects use ant sript to build/deploy EAR/EJB/WAR. So you can use any project structure. It's metter of ant file to handle it. But JBoss Tools depends on Eclipse Web Tools. And you have to have WTP-strucrtured projects to have whole set of features.  For EAR deployment type it creates 4 projects: EAR,EJB,WAR,Test. And there are two projects in case of WAR deployment: WAR,Test.

          source: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4216787#4216787


          So the root cause of the 4 folders is WTP compatibility with JBoss Tools (very bad restriction!)


          It's very confusing b/c when you look at any of the example projects in the Seam distro, they all have the standard one high level root folder structure.


          This is another reason why the ramp up time with Seam is very high... :(


          /-------------------------------------------------------------------------------------------------------------------/


          Answers to your questions:



          1. WTP


          2. ant explode


          3. if you ran 'seam generate' the following happens:


          Generate CRUD pages and controllers for an existing database
          schema.  Combines the generate-model and generate-ui commands to
          create the JPA entity classes and then the pages and controllers
          that allow them to be managed.




          So if you add a column, you can manually update your entity class to reflect that change and any requisite metadata (e.g. @OneToMany, etc.) for that column.  Or you can re-run 'seam generate-model' to refresh your entities.


          Keep in mind that Seam has something called SAF (Seam Application Framework) which supports full CRUD operations via EntityQuery and EntityHome classes, etc. and creates a working but basic CRUD application after you run the appropraite seam-gen commands.


          You may not necessarily want to use this depending on your use cases (obviously your functional requirements and use cases will make the views generated completely unusable).


          My preference is to reverse-engineer my database schema so I have my entity classes (bottom-up approach) and write the xhtml and Seam components (EJB, JavaBean, etc.) by hand.  You will also need to configure the pages.xml file for page navigation and exception handling, etc.


          enjoy.

          • 2. Re: Jboss Seam - Confusion on Project Structure
            Varun Chopra Newbie

            Thanks Arbi for detailed response.


            I have couple of more question,


            a) Where is purpose of pages.xml explained in SEAM documentation?


            b) I am assuming pages.xml has to do with SEAM, not JSF. I mean I could not find reference to pages.xml in a JSF book that I have.