[jboss-user] [JBoss Tools (users)] - Re: Launch Files: Real control of Seam-Gen
max.andersen@jboss.com
do-not-reply at jboss.com
Sun Jul 13 03:28:39 EDT 2008
"luxspes" wrote :
| 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.
|
Yes, that is the default behavior.
anonymous wrote :
| We use JBossTools 2.1.1 and store our seam-gen configurations in Eclipse .launch files (and call them using the Code Generation Launcher).
|
Nice to see the .launch saving feature being used as intended (sharing of custom code generations)
anonymous wrote :
| 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" />
| |
|
For the moment for_each is hardcoded to only understand the Configuration notions of Pojo's (e.g. entity and component)
I have considered adding table, foreign_key etc. too since they are "concepts" in the Configuration API but it felt wrong to do so (entities and database level concepts being mixed up).
What I have considered was to add some way to put an expression in for_each that could be iterated but that haven't been done yet (contributions welcome! :)
That being said there is way to do what you want - read below.
anonymous wrote :
| (And then create my own custom @ReadOnlyEntity annotation to control generation)
|
Sounds doable - you could also use the mutable attribute of Hibernate to state it (if that fits the bill enough)
anonymous wrote :
| 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 (inheriting I think)... 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"
| | />
| |
|
Custom exporters are only really needed if you want very specific iteration and setup of the contexts - you can do without it in this specific case.
anonymous wrote :
| Docs do not explain how to configure the exporterclass in a eclipse *.launch file (or if is even possible)...
|
| How can I do that? (Do I need to modify the Eclipse Jboss Tools code? or this features is available but undocumented?)
|
the hbmtemplate exporter has a property exporter_class you can set - just like ant ;)
But now to how you can do it with less tweaks. I deliberatly made it so that if a template generates a trimmed empty string (e.g. a file with zero contents) then the file would not be generated.
That means you can simply put an expression in the top of the template and decide if something needs generating or not.
See http://freemarker.sourceforge.net/docs/ref_directive_if.html how to create and #if block.
anonymous wrote :
| P.D. Sorry for cross posting, but I posted this question at SeamFramework.org and nobody answered, and I am starting to think that maybe that is because this forum is a better match for this kind of question because it is more related to JBoss Tools than Seam
|
No problem - you did the right thing by posting here.
I try to monitor the Seam forum but I don't always catch the tool related questions, plus I just came back from vacation :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164066#4164066
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164066
More information about the jboss-user
mailing list