3 Replies Latest reply on Jul 17, 2008 7:40 PM by luxspes

    Lauch Files: Real control of Seam-Gen

      Hi!


      We (in my project) have heavily modified and enhanced the functionality of seam-gen, but I think we are hitting a hard limit: we can not say do not generate the EntityEdit.xhtml because that is read-only. No matter what we do, all the *.ftl templates get called for all the our entites.


      We use JBossTools 2.1.1 and store our seam-gen configurations in Eclipse .launch files (and call them using the Code Generation Launcher).


      The initial from database to entities configuration is in a file named:projectname-generate-entities.launch, after that I create a file named: projectname-generate-pages.launch that creates  from the entities to the pages .


      The difference is that projectname-generate-entities.launch only uses 1 exporter, the Domain code exporter (extract of projectname-generate-entities.launch):


              <booleanAttribute key="org.hibernate.tools.exporters.hbmtemplate0"
                      value="true" />
              <stringAttribute
                      key="org.hibernate.tools.exporters.hbmtemplate0.extension_id"
                      value="org.hibernate.tools.hbm2java" />
              <mapAttribute
                      key="org.hibernate.tools.exporters.hbmtemplate0.properties">
                      <mapEntry key="template_path"
                              value="\seam-templates\hibernate-tools" />
              </mapAttribute>
      



      On the other hand projectname-generate-pages.launch is much larger (here is only the part that generates the EntityEdit.xhtml:


      <mapAttribute
              key="org.hibernate.tools.exporters.hbmtemplate4.properties">       
              <mapEntry key="outputdir" value="/applicationName/WebContent/" />
              <mapEntry key="for_each" value="entity" />
              <mapEntry key="template_name" value="view/edit.xhtml.ftl" />
              <mapEntry key="file_pattern" value="{class-name}Edit.xhtml" />
              <mapEntry key="hibernatetool.util.toolclass"
                  value="org.hibernate.eclipse.launch.SeamUtil" />
          </mapAttribute>
      



      As you can see, the  exporter configuration for EntityEdit.xhtml is very different, and one of themain differences is that it has a :


      <mapEntry key="for_each" value="entity" />
      



      now, i would like to extend this mechanism to make it possible to generate the EntityEdit.xhtml only for... for example non-readonly entities (or any other criteria that I choose):



      <mapEntry key="for_each" value="readonly-entity" />
      



      (And then create my own custom @ReadOnlyEntity annotation to control generation)


      My plan to achieve that effect was to create my own exporter, to do that, I need to configure a Generic Hibernate metamodel exporter and create my own exporter class... but here is my problem... the docs only explain how to set the exporter class for ant:


      <hbmtemplate
       filepattern="{package-name}/{class-name}.ftl"
       template="somename.ftl"
       exporterclass="Exporter classname"
      />
      



      They do not explain how to configure the exporterclass in a eclipse *.launch file (or if is even possible)...


      How can I do that?


      Regards,