I wanted to work with JSF ever since I had used Sun's Java Studio Creator back when it was in early access.
WOW, I thought to myself, finally a WYSIWYG IDE for web applications.
I was blown away...
But soon, working on a test project, the IDE bugs haunted me, not even going away with the final and updated version of the creator...
When it was merged into NetBeans I tried it again, but something didn't feel right... Sun's enhanced JSF library ( Woodstock ) was very propriatory and the future seemed to be JSF and JPA.
But the JSF/JPA project from NetBeans was without visual help...
Also, pure JSF/JPA has a very tricky way to get paging working with very large datasets which was not drag&dropable in NetBeans. ( JSF DataModel )
Hmm, I was unhappy, what was left of Sun's Java Studio Creator's promise ?
Searching the web for JSF libraries I found ICEFaces.
They didn't solve the paging problem, but had very powerful AJAX features on top of JSF.
Later I even found a promising paging demo in the then unreleased 1.8 examples... I was getting hopeful again.
I played around with ICEFaces using the Eclipse plugins for two days just to understand the basics... quite a steap learning curve.
( Keep in mind I never wrote JSF by hand before, as Creator did all of that for me... )
Hmm that wasn't perfect either, why do I need managed beans if I have an entity bean with all the same values ?
That was when I found Seam and its way of getting rid of much config XML and those stupid managed beans. I had heard about it before so I decided to give it a try.
Cool, there are even eclipse plugins for it, the JBoss Tools !
But WOW, they are overwhelming... so many new options, so many new resources.
I needed to take a step back, so I looked for a Seam book and found the so far, very good to read Seam in Action from Manning ( http://mojavelinux.com/seaminaction )
But the book used the seam-gen command line tools... not what I wanted.
But hey, I gave it a try and it worked, but still, I wanted to work in a IDE and have tool support. ( Yes, I know I can import a seam-gen project... )
So I went back to the IDE and startd to play around. At least now I had a better understanding of the terminology. So the book helped me alot to get myself comfortable with the tools. ( BTW: http://www.jboss.org/tools )
The online documentation for the tools don't help at all with what to do after a project is generated... How to turn in it into your project.
So more playing around was necesary, and boy was it painful.
Let me give you some of the most important things I learnd so far:
1. Use old stuff !
Use the last version of: Jboss application server ( 4.2.3 not 5.X), Seam ( 2.0.X maybe 2.1 ), Java (1.5 not 1.6)
If not you will be in for a lot of pain!
So much stuff goes wrong if you want to make a WAR project if you switch out one of these things with a current version.
( EAR works better, but overwhelmes again. )
You can use the current Jboss Tools, that's ok.
2. Don't use a DB in embedded mode.
DON'T use a java DB like HyperSonic SQL in embedded mode !
The tools and JBoss App Server NEED concurrent access and you will get so much frustrating trouble if you do...
I used HSQLDB embedded first because it was easy... don't !
Read the docs how to run it in stand alone server mode and do it.
3. Customizing the reverse engineering process
You will never guess how to customize the Java classes and attribute names if you generate your entities from an existing DB with JBoss Tools:
In the Seam perspective there is a little new run button with a hibernate symbol. There is a sub option called: "Hibernate Code Generation Configurations..."
There you will find a configuration for your project if you executed "Seam Generate Entities" in the "New" Wizard.
Its this magic place where you can browse to a reveng.xml file which you create easily prior with the hibernate tools ( part of JBoss Tools ).
And then rerun and voilà new entities and xhtml files
( Now you just need to get rid of the old ones :-(
Also, this did not work with MySQL for some reason, but with HSQLDB )
Please JBoss guys, add a page in the Seam wizards for a reveng.xml file !!!
4. Schema Validation
If you generate a project from existing tables, the tools will set the hibernate.hbm2ddl.auto property to validate... boy will you get errors!
You will scramble, you will search, you will change java code and table column types. The easy fix ? Remove the word validate leaving emtpy "" quotes...
5. Restrictions ( This is the best ! )
Great now you have a nice little web application, much like phpMyAdmin.
Everyone can see everything... logged in users additionally can change everything.
But thats not what you want, many times you want users to see their own stuff only !
How can you do that with classes extending EntityQuery which provide the tabular data ?
Should you do something to that getEjbql() function maybe ?
No, add restrictions !
In the generated class you will see a RESTRICTIONS constant.
The trick is to know that you can add any restriction to that array and Seam will use and add that restriction if and only if the expression language (EL) variable in the string has data.
So in my authenticate method I simply set a variable in a new session scoped component which I use in my restriction.
WOW, I found this 3 days trying to find a solution for this.
( Yeah, I bet the book explains it later too... but I'm only in chap 3 )
I may write a little tutorial on how to make a Seam WEB project your own.