[cdi-dev] Stafeful services directly from the JSF VS "ViewBean" + stateless service
dan.j.allen at gmail.com
Fri Dec 23 19:29:32 EST 2011
On Thu, Dec 22, 2011 at 05:49, José Rodolfo Freitas <
joserodolfo.freitas at gmail.com> wrote:
> CDI created the possibility to reach any bean in the container from a JSF
> view, encouraging a closer approach between ejb and jsf (or any cdi bean
> and jsf), which can potentially lead to a simpler application design. I
> think that is great!
> However, I'm observing that this new programming model has been
> experimenting user resistance. The "traditional" way of doing things, using
> a "ViewBean" accessing a Stateless Service seems to be the
> more legit.
> What do you think about this? I'd like to discuss best practices around it
> as I see it's on the core of almost every web application design.
The way I've always looked at this is that the initiative to flatten the
tiers in the Java EE platform was always focused on making the platform
more approachable. When you read tutorials that require many technical
steps that doesn't seem to add any value, the perception is that the
platform is overkill. Why create two beans when one will do?
I think that once an application matures, many of your UI interactions will
go through a controller layer that mediates between the view and the
services. If you're an experienced developer, this maturation may occur as
early as the design stage, in which case you never even write any code that
uses the flattened architecture. But it's critical for tutorials &
Another way to say this is that there is no reason to enforce a middleman.
Why can't the UI just invoke any service you expose directly? There will be
plenty of cases when that's reasonable. If there is a reason it shouldn't,
that should be a restriction you impose, not one that the platform imposes.
So I advise you to not feel shy about creating a view controller if it
feels right. You should only observe yourself creating a bean that does
nothing but delegate to another bean and ask why you are doing that.
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cdi-dev