[ADF EMG] Beans and JSF, beans and ADF Faces, beans and scope, beans beans beans

877 views
Skip to first unread message

Chris Muir

unread,
Apr 22, 2010, 4:01:29 AM4/22/10
to ADF Enterprise Methodology Group
I'd like to carry on from the recent Clusters vs ADF post about JSF
bean scopes.

This post is partially inspired by Blake Sullivan's post about the
careless use of Session beans:
http://leadingyouastray.blogspot.com/2010/02/references-to-uicomponents-in-session.html

Simon Lessard also made strong comments to the same effect in the
recent ADF EMG Clusters vs ADF post:
http://groups.google.com/group/adf-methodology/browse_thread/thread/32100c089d180a65?hl=en

And for beginner's reference Oracle's latest documentation on bean
scopes for ADF 11g is here:
http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/taskflows.htm#CHDFAIGC

Setting the ground work above, I'd like to throw a couple questions
out there first and see what members think followed by some general
discussion points. Firstly the following 2 questions were recently
put to me. I'll reserve my opinion to see what other members have to
say:

1) Is understanding bean scope essential for JSF/ADF programming?

2) As extension, is it essential for JSF/ADF beginners?


Secondly, does anybody in 11g agree with me that the new bean scopes
for ADF, namely pageFlowScope and backingBeanScope are badly named and
causing confusion among the beginner community? I'm not going to say
why I believe that, but again rather wait and see what opinions others
come up with.


And finally third and most controversially (well at least I hope), do
you think the whole scoped bean things is a just an ongoing disaster
for JSF beginners, and, what a vendor like Oracle should do is come up
with a mechanism where the programmer doesn't have to worry about the
scope of the bean.

(of course I've no idea how this would work, maybe you do?.... but
given beginner programmers aren't getting it right anyhow, maybe the
Oracle should solve the problem for us.... it's kind of like how so
many DBAs were screwing up rollback segments in their database, so
what did Oracle do? ... they changed the database so it manages them
itself)

Idle Thursdays musings. Your thoughts and comments welcome.

CM.

--
You received this message because you are subscribed to the ADF Enterprise Methodology Group (http://groups.google.com/group/adf-methodology). To unsubscribe send email to adf-methodolo...@googlegroups.com

Matthias Wessendorf

unread,
Apr 22, 2010, 4:36:58 AM4/22/10
to ADF Enterprise Methodology Group
Hi,

On Apr 22, 10:01 am, Chris Muir <chriscm...@gmail.com> wrote:
> I'd like to carry on from the recent Clusters vs ADF post about JSF
> bean scopes.
>
> This post is partially inspired by Blake Sullivan's post about the
> careless use of Session beans:http://leadingyouastray.blogspot.com/2010/02/references-to-uicomponen...
>
> Simon Lessard also made strong comments to the same effect in the
> recent ADF EMG Clusters vs ADF post:http://groups.google.com/group/adf-methodology/browse_thread/thread/3...
>
> And for beginner's reference Oracle's latest documentation on bean
> scopes for ADF 11g is here:http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/taskflow...
>
> Setting the ground work above, I'd like to throw a couple questions
> out there first and see what members think followed by some general
> discussion points.  Firstly the following 2 questions were recently
> put to me.  I'll reserve my opinion to see what other members have to
> say:
>
> 1) Is understanding bean scope essential for JSF/ADF programming?
>
> 2) As extension, is it essential for JSF/ADF beginners?


I'd say yes. If you add more and more stuff to the session, you start
to get an ugly design and you waste memory.

Also if the stuff that you put to the session is not serializable (or
it's
members) you will notice issues on failover.

So, yes.. scopes are important to understand. Session (and/or
application)
scope maybe convenient, on first hand, but there is a tax (see Blake's
blog :-) )

>
> Secondly, does anybody in 11g agree with me that the new bean scopes
> for ADF, namely pageFlowScope and backingBeanScope are badly named and
> causing confusion among the beginner community?  I'm not going to say
> why I believe that, but again rather wait and see what opinions others
> come up with.
>
> And finally third and most controversially (well at least I hope), do
> you think the whole scoped bean things is a just an ongoing disaster
> for JSF beginners, and, what a vendor like Oracle should do is come up
> with a mechanism where the programmer doesn't have to worry about the
> scope of the bean.

BTW. for ADF/Trinidad we introduced a neat facility if your bean
really needs
to have referneces to beans...

http://matthiaswessendorf.wordpress.com/2010/03/31/uicomponent-references-in-session-scoped-jsf-beans/

Andrejus Baranovskis

unread,
Apr 22, 2010, 4:38:50 AM4/22/10
to adf-met...@googlegroups.com
I dont know if its possible to work with ADF without understanding bean scopes.
 
As a minimum, ADF developer should learn the difference between pageFlowScope and backingBeanScope. Otherwise customers will complain why ADF is so buggy and slow :) 
 
I personally like pageFlowScope bean name. But, I think that backingBeanScope name is confusing. As developer guide says, backingBeanScope is introduced mainly because Reusable Components, so it should have a more suitable name. Now with mix both request and backingBeanScope too often.
 
Andrejus
--
Oracle ACE Director

My Blog - http://andrejusb.blogspot.com/
My JDev/ADF Samples list - http://andrejusb-samples.blogspot.com/

Zeeshan Baig

unread,
Apr 22, 2010, 4:47:22 AM4/22/10
to ADF Enterprise Methodology Group
Hi,

I guess you came up with this post regarding question at OTN forums.
Well my views on your 2 points would be YES

1) Is understanding bean scope essential for JSF/ADF programming?
2) As extension, is it essential for JSF/ADF beginners?

it is important to know the details about your programming language
and tools to achieve results....ultimately you need to know if not
today then you will stuck somewhere tomorrow.

May be out of topic but i think it is related the main problem with
ADF is it is 360 degree turn for Oracle FORMS developers.... specially
with JEE technology

Switching to JSF/ADF someone need to know a lot before getting into
this world... With FORMS it was easy all you need to know just SQL and
PL/SQL and you are ready...now with ADF you cannot start as like FORMS
you need to know Java, Groovy, XML, CSS, HTML and some more java
technologies like JSF, EJBs, JAAS, JNDI etc etc.

Problem with beginners is they want a magic stick :-)

Regards,
ZB


On Apr 22, 2:01 pm, Chris Muir <chriscm...@gmail.com> wrote:
> I'd like to carry on from the recent Clusters vs ADF post about JSF
> bean scopes.
>
> This post is partially inspired by Blake Sullivan's post about the
> careless use of Session beans:http://leadingyouastray.blogspot.com/2010/02/references-to-uicomponen...
>
> Simon Lessard also made strong comments to the same effect in the
> recent ADF EMG Clusters vs ADF post:http://groups.google.com/group/adf-methodology/browse_thread/thread/3...
>
> And for beginner's reference Oracle's latest documentation on bean
> scopes for ADF 11g is here:http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/taskflow...

Grant Ronald

unread,
Apr 22, 2010, 5:02:10 AM4/22/10
to adf-met...@googlegroups.com
Chris, the Jdeveloper handbook (Mills, Koletzke, Roy-Faderman) page 375
does acknowledge the fact that these names are confusing, so you are not
alone.

From the 3 answers so far who all said YES, I probably need to clarify
something since it me that kicked off this discussion with Chris :-)

Yes, you have to know this stuff - I'm not saying you should start
building a production application and not know about scope/managed
beans, but if you are a newbie to ADF and you have to understand EOs
VOs, AM, EntityImpls, ADF Faces, layout components, task flows, view
activities and a million other things before you can start screwing up
your application with bean scope.

If I'm teaching my mother to be a Java programmer I'm going to start
with "this is a computer" before I explain polymorphism :-)

One comment that used to come up with a colleague when discussing the
"challenges" of the technology we work with is it is too easy to forget
what it was like being a newbie. Just think if you come from a
Forms/PLSQL world and you can't even spell ADF, but your boss made a
decision that you next project will be writing and ADF application. The
dev guides alone are about 3000 pages!! You have to really break out
what is important to learn on day one, and what you can leave until day
10. I think this is one of the biggest challenges we have in learning
ADF - not being swamped - and that's why I decided to write the Quick
Start guide to ADF (advertisement: coming to a bookstore near you! :-) )

With your newbie head on and taking task flows as an example, I'd say
that once you have a solid understanding of what they are, what they do
and how you build them, THEN you can say, "ok, you can also reference
these things called managed beans, and there is a thing called scope...."

Again, I'm not say DON'T learn about scope/managed beans before starting
a real project, thats just crazy - but when you are building up your
skills start with simple concepts that you can then build upon. Start
with Dr Seuss before tackling "War and Peace" :-)

Regards
Grant

Marko Mitic

unread,
Apr 22, 2010, 5:31:41 AM4/22/10
to adf-met...@googlegroups.com
I agree with Andrejus that name of "backingBean" scope a little bit confused. Also, you can develop very complex application (a lot of taskFlows, regions) without using backingBean scope (even using reusable components) and you can't feel any difference in performance. Personally, I using this scope but I think beginners don't use.

Instead of backingBean I think viewScope is very useful and developers must good understand differences between request, view and pageFlow scope.

Oracle introduce Task Flows in 11g as a main part of ADF controller and Views (no Pages) as part of Task Flows. So, maybe better name for "pageFlowScope" is "taskScope" because of Oracle terminology for Task Flow and Views inside it. PageFlow exist from beginning of ADF (when pages was pages) and for experience web developers this name is good and logic but for total beginners can be confusing.


Regards
Marko Mitic

--
Marko Mitić
Bul. Kralja Aleksandra 249/62
11000 Belgrade
Serbia
Phone. +381 (0)63 7737328

Simon Lessard

unread,
Apr 22, 2010, 8:59:13 AM4/22/10
to adf-met...@googlegroups.com
Hi all,


1) Is understanding bean scope essential for JSF/ADF programming?
2) As extension, is it essential for JSF/ADF beginners?

Yes, it should be one of the first notion to understand. by extension, the beginner must understand what the HTTP session and request are and what are their limitation.
 

Secondly, does anybody in 11g agree with me that the new bean scopes
for ADF, namely pageFlowScope and backingBeanScope are badly named and
causing confusion among the beginner community?  I'm not going to say
why I believe that, but again rather wait and see what opinions others
come up with.

Personally I think backingBean scope name is fine if you consider that a managed bean is considered a backing bean if you bind components to it. I always give my trainings in that sense and therefore it rarely get confused. We use the following pattern in our project:

- Stateful beans containing data (sometimes directly business entities) are placed in the page flow scope
- Controller beans are placed in the backing bean scope and have the relevant data injected in them as managed properties
- You can bind components in controllers, never in data beans
- Data beans cannot contain any listener methods, those are all in the controller
- We have one main controller per task flow and sometimes some smaller helper ones.

Page flow scope in Trinidad is fine, in ADF, rather than overriding the PageFlowScopeProvider, I think they should have created a task flow scope.

View scope is under rated and should be user more often.

A view scope - backingBean scope combo should have been created as well as you can have issues with backing bean in backing bean scope as well if you have two fragments with, let say, a content panel, that you want to bind in both pages and happen to want to bind it on the same controller property because various actions wants to refresh that panel. On the request that will navigate from fragment1 to fragment2, there will be a bug if the controller's component getter doesn't return null as the component from the first page will be used in the second page. Therefore, we have another rule on our projects:

- Public getter method for bound components should always return null. If the controller sub classes might need to have access to the bound component, expose a protected method returning it, or expose a public or protected method doing the required action. Like in the content panel example, we often have something like.

public UIComponent getContent()
{
    return null;
}

public void setContent(UIComponent content)
{
    this.content = content;
}

public void refreshContent()
{
    addPartialTarget(content); // addPartialTarget is from our base controller class and does the component != null check
}
 


And finally third and most controversially (well at least I hope), do
you think the whole scoped bean things is a just an ongoing disaster
for JSF beginners, and, what a vendor like Oracle should do is come up
with a mechanism where the programmer doesn't have to worry about the
scope of the bean.

(of course I've no idea how this would work, maybe you do?.... but
given beginner programmers aren't getting it right anyhow, maybe the
Oracle should solve the problem for us.... it's kind of like how so
many DBAs were screwing up rollback segments in their database, so
what did Oracle do? ... they changed the database so it manages them
itself)

No, and I'm quite harsh on this point and sometimes get very annoying about it. To me, this kind of question is similar to asking if a provider should do everything in its power, sometimes sacrificing performance, usability and correctness, to circumvent the mediocrity of developers. That being said, I might be a bit radical here in my purist and strict point of view, but I still think it's for the best in the long run. This is also a huge issue in the industry imho, training is not favored enough, not enough time is given to architecture and analysis either, resulting in poor to horrible quality code. I've seen some unnameable things that would induce terror in any of Lovecraft's horror or make Voldemort a not so bad thing to name after all. I believe the IT business grew too fast, resulting in a too high head count and many competency sacrifices. It's not that programming should be reserved to the elite, it just that a doctor has to learn the difference between a scalpel and a stethoscope before he can practice and, in the same way, a developer should learn his trade before being allowed to write a single line of code in an enterprise application.


Regards,

~ Simon
 

Idle Thursdays musings.  Your thoughts and comments welcome.

CM.

--
You received this message because you are subscribed to the ADF Enterprise Methodology Group (http://groups.google.com/group/adf-methodology). To unsubscribe send email to adf-methodolo...@googlegroups.com

Rommel Pino

unread,
Apr 22, 2010, 8:59:47 AM4/22/10
to adf-met...@googlegroups.com
 "When creating a managed bean for a page fragment or a declarative component, you must use backing bean scope."

The statement above from the Fusion Developer's Guide for ADF is quite strong. It says "you must" and not just "you can".

That is explicitly stated not once but at least twice. Here is the other one as depicted in Figure 21-3 Relationship Between Scopes and Page Flow:
"BackingBean Scope- One for each JSFF or Declarative Component within a bounded task flow on the page."

In my opinion, "backing bean scope" is just properly named. It encourages newbies to use that scope if they need to have a backing bean to support a page fragment.

There is one thing that is clear here. The Oracle ADF Team should explain more on the developer guides, the differences of the scopes.

Regards,

Pino
http://soadev.blogspot.com

Andrejus Baranovskis

unread,
Apr 22, 2010, 9:22:24 AM4/22/10
to adf-met...@googlegroups.com
Unfortunatelly, JDeveloper not always works as it is described in Developer Guide :-) And in reality, many projects have a different combinations of request scope and backingBeanScope usages. Developers very often are confused between these two.
 
If Backing Bean Scope is designed for JSFF and Declarative Component, why JDeveloper allows to use it for pages as well? Instead of Backing, it would be more clear to have Declarative Bean Scope, for example :)

Jan Vervecken

unread,
Apr 24, 2010, 4:38:29 AM4/24/10
to ADF Enterprise Methodology Group
hi

What Grant Ronald points out makes sense. It is important to know
about the different scopes, but possibly not the very first thing you
need to understand.

At Oracle OpenWorld 2009 Frank Nimphius made a fair one-slide-attempt
to alleviate some scope-confusion,
see http://www.consideringred.com/files/oracle/img/2010/OOW2009-FrankN-AvailableObjectScopes.png
It does not mention backingBean scope, but maybe Frank has a variation
on this slide available somewhere that does include backingBean scope.

regards
Jan Vervecken
Reply all
Reply to author
Forward
0 new messages