On Thu, Dec 22, 2011 at 05:49, José Rodolfo Freitas <span dir="ltr">&lt;<a href="mailto:joserodolfo.freitas@gmail.com">joserodolfo.freitas@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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!<div>


<br></div><div>However, I&#39;m observing that this new programming model has been experimenting user resistance. The &quot;traditional&quot; way of doing things, using a &quot;ViewBean&quot; accessing a Stateless Service seems to be the </div>


<div>more legit.</div><div><br></div><div>What do you think about this? I&#39;d like to discuss best practices around it as I see it&#39;s on the core of almost every web application design. </div></blockquote><div><br></div>

<div>The way I&#39;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&#39;t seem to add any value, the perception is that the platform is overkill. Why create two beans when one will do?</div>

<div><br></div><div>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&#39;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&#39;s critical for tutorials &amp; prototypes.</div>

<div><br></div><div>Another way to say this is that there is no reason to enforce a middleman. Why can&#39;t the UI just invoke any service you expose directly? There will be plenty of cases when that&#39;s reasonable. If there is a reason it shouldn&#39;t, that should be a restriction you impose, not one that the platform imposes.</div>

<div><br></div><div>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.</div>

<div><br></div><div>-Dan</div><div> </div></div>-- <br><div>Dan Allen</div>Principal Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><div><a href="http://google.com/profiles/dan.j.allen" target="_blank">http://google.com/profiles/dan.j.allen</a><br>

<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br></div><br>