I've been on this list for awhile now and I don't
remember a discussion about how to architect managed
beans for a page. (Please bear with me as this has
turned into a rather long post.) I see 2 alternatives
with how to set up the classes for my managed beans.
First, for sake of discussion, here is my problem set.
On my page I have 2 selectOneMenu lists and 1
dataTable. The first selectOneMenu is a list of
subjects, the second is a list of teachers, and the
dataTable is a list of classes. Selecting the subject
and teacher determines which classes will be displayed
in the list of classes. The list of classes is
displayed when the search commandButton is clicked.
Now, the question is, do I have just 1 managed bean
for the page? That bean would have as a class
variables, a teachers list, a selected teacher String,
a subjects list, a selected subject String, and a
classes list. Then for methods it would have all of
the getters and setters for these fields in addition
to the method for the commandButton. The method for
the commandButton would call the business layer to
actually retrieve the list of classes from the data
layer. The getter for the teacher list would call the
business layer to actually retrieve the list of
teachers, etc.
I could have another page in my app (or another app),
that needs an inputText field for a teacher, and
possibly a method to validate the name entered to see
if it was valid.
So with this design managing of teacher information
would be spread across multiple beans.
Or, do I have 1 managed bean per object. So I would
have a managed bean to manage teacher information, a
managed bean to manage subject information, and a
managed bean to manage class information.
This would group all of the presentation for an object
into 1 class, but it causes complexity when one class
needs access to the information in another class in
order to retrieve its data. It also seems to make the
managed bean organized more like the data layer than
the presentation layer.
In either case, the managed bean would just be for
passing the data to the JSF page and for calling the
business layer to retrieve, maintain, etc, the data.
I like aspects of both designs.
Maybe there is another better solution. I have just
been learning the tags and haven�t given much thought
to the design of the beans yet. But it�s time for me
to start thinking about how to set up my managed
beans, hence I am asking for your advice.
>From an OO perspective, which way do you experienced
JSF programmers have things set up?
Thanks,
Ray
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail