This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Seam Application Framework -- when to use or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Seam Application Framework -- when to use or not?" Watch "Seam Application Framework -- when to use or not?" New topic

Seam Application Framework -- when to use or not?

Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
For those not familiar with the Seam Application Framework within Seam (yeah, probably a bad name) it provides a lot of the functionality we end up using for CRUD and searching the data model. That puts it very lightly, Dan expounds on this at length in Chapter 11 of his book.

My question to everyone out there familiar with Seam (not just Dan) is when to use it and when to simply inject the EntityManager (or Hibernate Session)? Sure the Query, Home, and Controller classes will take you a long way (and it's a great place to see how Seam works), but is there some point where they simply don't provide enough capability?
Dan Allen
Ranch Hand

Joined: Mar 05, 2003
Posts: 164
I'd love to hear what other folks have to say, though I am sure there are those that are eager to know what I think. First and foremost, check out chapter 10 (to correct Jason) of Seam in Action to learn the ins and outs of this subframework in Seam.

The Seam Application Framework is a great way to start with Seam. It saves you a lot of time and if the use case fits, you can even get away without writing any Java code at all. You merely configure it in XML. From there, you can extend the framework classes to get more functionality out of them, perhaps even to create your own abstract classes. I have done this with much success. Before you abandon the framework and start from scratch developing your own components, in which you would inject an entity manager, think about injecting a Seam Application Framework class, in a sense taking a hybrid approach.

With all of that said, if you are ready to go at it on your own, rather than try to extend what Seam has to give you, be a villain and steal the code! It's open source after all and that is the beauty of it. I have a client right now who used the Seam Application Framework as an open book and implemented a similar hierarchy of classes, but tuned it to his needs.

One point I want to make about Home. The Home class is unique in that it goes another step in preventing the LazyInitializationException because it fetches the record before JSF applies updates to it, so even if you are outside of a long-running conversation, you don't have to merge to have those changes detected. Recall that once you load the record from the persistence context, it starts monitoring the object for changes. Because of the ordering that Home uses, you get that for free (i.e., without thinking about it). What you lose by not using a long-running conversation is the optimistic locking guarantee.

As a final note, I love using the Query framework to back lookups for a select menu (i.e., lookup tables). I don't have to write code and I can centralize my queries in components.xml.

I now turn the table over to the audience.

Dan Allen | | Author of Seam in Action -
Jason Porter
Ranch Hand

Joined: Apr 26, 2007
Posts: 120
Err, uh Chapter 11 is about Security... very good chapter, nice stuff... Am I out of the hole yet?
I agree. Here's the link:
subject: Seam Application Framework -- when to use or not?
Similar Threads
Seam and ADFm
How long will the Seam project be active before people focus is placed on WebBeans?
Seam in Action: is Seam stable if I want to build an application in production?
Should I be using Seam?