Re: BaseBean questions [was] [ANN] Struttin' With Struts beta (newbiesesp. welcome)

2003-03-13 Thread Vic Cekvenich


Rick Reumann wrote:
On Thu, 13 Mar 2003 06:22:58 -0500
Vic Cekvenich [EMAIL PROTECTED] wrote:
 

Also, a bean should not do persistence, but should delegate. So I
create a helper object, a DAOImplementation. ( a DAO also has a
base). One thing is obvoice, a baseBean needs to CRUD, so it makes
sense to baseBean { public void save() { DAO.update(); }}


I love the OO approach to your code, I'm just still very confused about
how a simple implementation of a BaseBean would work in calling a DAO to
save itself? In other words, what gets passed to the DAO from the
BaseBean implementation to do the CRUD?
For example in a case where you had:

EmployeeFormBean extends BaseBean

I would take it EmployeeForBean would need to hold user fields such as
firstName, lastName, address, etc with appropriate getter and setters.
How do these fields then get passed to your DAO for the CRUD operations?


A bean has getters and setters as you said, and it gets and sets them to 
a list (of a maps), where a list is a property of the Bean!
So that is why I say list/collection backed bean.
So no DAO here, and simple to fake for a prototype, even multi row.

Then on
bean.save(){
myDAO.update(localList);
}
That is the beans part! It delegates, so no magic or secret.
3rd, in DAO update (list l) {
// code to intalize a transaction
// code to iterate the list
// code to update each row
//code to commit, release
// Suprisingly, this code can be generic/reusable via OO
}
Yes, your implemenation is great. I will walk you over the phone.

hth,
V

Thanks,



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


BaseBean questions [was] [ANN] Struttin' With Struts beta (newbiesesp. welcome)

2003-03-12 Thread Rick Reumann
Thanks vic for the kind words and feedback. I replied to you privately.
Rest of this email is in regard to the BaseBeans stuff I looked it.
Comments below...

On Wed, Mar 12,'03(08:51 PM GMT-0500), Vic wrote:
   
 So consider using list/collection based beans. Ex:
 http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/bP/WEB-INF/src/war/org/apache/scaffoldingLib/base
 Note that I use iBatis.com DAO, a good and fast SQL based DAO.
 

I've been looking at the classes from the link above and I think
what would really help me is seeing an actual web app implement the
org.apache.scaffoldingLib.base.BaseBean and see it being used for CRUD
operations. I think you had a web app to download on your basebeans.com
site but I'm not sure what to download to see this in action (should I
look at the Portal download?)

For the sake of this discussion lets consider an application that would
allow a user to view Employees, insert an employee, update an employee
etc. (I'm thinking of updating my lessons, with your approval of course,
to incorporate some of these ideas, but I want to make sure I understand
them first:)

Using the List backed BaseBean idea, it appears that all the ActionForm
beans would extend BaseBean. I guess the big difference in this
approach, compared to the others I've seen documented, is your Form
beans are actually responsible for a lot more than just being holders
for simple form field properties.

So lets take a typical example of where a user wants to update Employee
information on a form.  I take it our EmployeeFormBean would have your
usual firstName, lastName fields, but then rather than pass this bean
off to be converted into a Data Transfer Object and then passed off to a
model layer to be updated, you would instead simply do something like
this in your Action:

(in the execute or dispatch method of an Action called for doing an
update):

EmployeeFormBean emp = (EmployeeFormBean)form;
emp.save(); //

To do this would we need to override the BaseBean's save() method? I
assume you also would need to provide an implementation of the BaseDAO's
update(List l) method? I'm really starting to get lost here:) I think I
need a simple walk through of what would take place upon a simple update
of an employee. I'm also confused what would be held in this List (what
type of objects is it holding) and how we would know what to update in
the List? 

I also don't see how the DAOIBase fits into the picture (it has a
doUpdate(List l, String s) method but none of the classes from the link
you gave seem to implement it. The BaseBean seems to want
implementations of DAO and not DAOIBase. 

I think I should stop asking questions until I first get a better handle
on an example implentation of a BaseBean and what kind of objects are
stored in the List that backs it. If the list is used for display
purposes, such as for displaying a List of employees to the user, I get
it (I think:).. you'd have an EmployeeFormBean (which extends BaseBean)
that stores a List of EmployeeBean objects (not EmployeeFormBean
objects). I'm not sure I have that use of the List backed Form Bean
correct? Assuming I do, I'm still really confused on how the
insert/update works using a BaseBean implementation.  Where does the
transfer take place from the FormBean fields that get submitted into a
bean that some DAO could use to successfuly peform the insert/update?

Im a bit under the weather so hopefully I didn't babble too much:) I'd
really like to understand the implementation of a BaseBean better since
it sounds very interesting (yet completely different from the way I've
been using FormBeans so far).
 
 

-- 
Rick Reumann
Struttin' with Struts: 
http://www.reumann.net/do/struts/main

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]