[cdi-dev] [seam-dev] Stafeful services directly from the JSF VS "ViewBean" + stateless service

Fabien Marsaud fabmars at gmail.com
Thu Dec 22 09:41:17 EST 2011


I agree with the fact the "traditional" way of doing things is hard ot get
rid of, I agree with Pete too, but if I may, I'd say it's often hard or
impossible to avoid some "view bean".

You can, when you only want to display stuff that doesn't need any 'UI'
reformatting.

Otoh, take a canonical CRUD: the submit button requires an action method
you don't have in your business layer. So it must go on a bean standing
behind the view.

Another example: feed a table on the screen. If the objects fetched from
the business layer can be displayed as-is, you can directly call the EJB.
But many developers will be reluctant to annotate it @Named. So you have to
wire your business methods through a view bean which is known to EL. Now,
if the elements on the table require any manipulation/action, you have to
encapsulate them and there's no other way but to get the cooking done on
some view bean.

And as development teams are required to work in a "normalized" way no
matter what's going to be on the screen, you end up having complete web
applications wiring all the biz methods through view beans.

After all I see no probmem with that, with CDI everyone can work the way he
wants. In my application I get all the db/xml configs via producer methods,
and I did a custom scope/context to refresh them without restarting
anything. So no matter whether you want to do simple of sophisticated
things, CDI has a solution in store.

fm.




On Thu, Dec 22, 2011 at 2:06 PM, Peter Muir <pmuir at redhat.com> wrote:

> IMO both approaches are valid in different situations, and it entirely
> depends on the app. If I have multiple view layers (eg jsf and jax rs I
> will likely want some sort of controller bean betweeny business layer and
> jsf, so as to not let jsf concerns leak. Otoh if it was just a web app with
> a jsf front end only, maybe I would dispose of this layer.
>
> --
> Pete Muir
> http://in.relation.to/Bloggers/Pete
>
> On 22 Dec 2011, at 11:36, "John D. Ament" <john.d.ament at gmail.com> wrote:
>
> I tried this a few times recently.  the main issue that pops up is that
> the EJB timeouts and WEB timeouts in the platform do not sync up.  so if
> you're idle on a page for 5 minutes, your stateful EJB disappears, unless
> you have someone change container config.
>
> On Thu, Dec 22, 2011 at 5:49 AM, 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.
>>
>>
>>
>>
>>
>> _______________________________________________
>> seam-dev mailing list
>> seam-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/seam-dev
>>
>>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
>


-- 
http://www.suntriprecords.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20111222/3308de16/attachment.html 


More information about the cdi-dev mailing list