[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-843) Generate application from existing entities

Gavin King (JIRA) jira-events at lists.jboss.org
Tue Feb 13 17:57:33 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-843?page=comments#action_12353006 ] 
            
Gavin King commented on JBSEAM-843:
-----------------------------------

Copy/pasting from the forum post:




This is the solution I have to get seam-gen to work on existing entities:
1) Either append the following target to the seam-gen/build.xml or just modify the generate-entities target:

[code]
<target name="generate-domain" depends="validate-project"
    description="Generate based on existing domain entities">

    <taskdef name="hibernate"
        classname="org.hibernate.tool.ant.HibernateToolTask">
        <classpath>
            <fileset dir="lib">
                <include name="*.jar" />
            </fileset>
            <fileset dir="../hibernate/lib">
                <include name="*.jar" />
            </fileset>
            <pathelement path="${driver.jar}" />
            <pathelement path="../jboss-seam-gen.jar" />
        </classpath>
    </taskdef>

    <hibernate templatepath=".">
        <jpaconfiguration persistenceunit="testproject" />
        <classpath>
            <pathelement path="${project.home}/dist" />
        </classpath>

        <property key="hibernatetool.util.toolclass"
            value="org.jboss.seam.tool.Util" />

        <hbmtemplate filepattern="{class-name}List.xhtml"
            template="view/list.xhtml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{class-name}.xhtml"
            template="view/view.xhtml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{class-name}.page.xml"
            template="view/view.page.xml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{class-name}Edit.xhtml"
            template="view/edit.xhtml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{class-name}Edit.page.xml"
            template="view/edit.page.xml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{package-name}/{class-name}List.java"
            template="src/EntityList.java.ftl"
            destdir="${project.home}/src" />
        <hbmtemplate filepattern="{class-name}List.page.xml"
            template="view/list.page.xml.ftl"
            destdir="${project.home}/view" />
        <hbmtemplate filepattern="{package-name}/{class-name}Home.java"
            template="src/EntityHome.java.ftl"
            destdir="${project.home}/src" />
        <hbmtemplate filepattern="menu.xhtml"
            template="view/layout/menu.xhtml.ftl"
            destdir="${project.home}/view/layout" />
    </hibernate>

    <taskdef name="javaformatter"
        classname="org.hibernate.tool.ant.JavaFormatterTask">
        <classpath>
            <fileset dir="lib">
                <include name="*.jar" />
            </fileset>
        </classpath>
    </taskdef>

    <javaformatter>
        <fileset dir="${project.home}/src">
            <include name="**/*.java" />
        </fileset>
    </javaformatter>

    <echo
        message="Type 'seam restart' and go to http://localhost:8080/${project.name}" />

</target>
[/code]
2) Run 'seam setup' and 'seam new-project' to generate the project skeleton

3) create a 'dist' directory under the newly created project directory

4) copy all your compiled classes for the domain model into the 'dist' directory 

5) copy all your src code for the domain model into the 'src' directory under the newly created project directory

6) create a META-INF directory inside 'dist' directory

7) copy the persistence-dev.xml from the resources directory in the newly created project to the dist/META-INF directory and rename it to persistence.xml

8) Now change the persistenceunit under <jpaconfiguration .../> in the seam-gen/build.xml to match the persistentunit in the persistence.xml

9) download the put the javassist.jar  into your [Seam installation dir]/hibernate/lib  directory

10) run seam generate-domain  (or seam generate-entities if you modify the ant target)


> Generate application from existing entities
> -------------------------------------------
>
>                 Key: JBSEAM-843
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-843
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Tools
>    Affects Versions: 1.1.6.GA
>            Reporter: Kent Lam
>         Assigned To: Max Andersen
>            Priority: Minor
>
> Would it be great that seam-gen will generate crud pages and classes for an existing Entity class,just like seam-gen generate the crud pages,classes and entity classes from database. 
> Thanks

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list