Hi,

I am trying to learn and create a working DB based application using struts. 
I have figured out following steps to follow, may be this is not the best 
practice. I would like to get some comments from struts and Java guru. 
Please feel free to correct me.

1. Create a EmpForm class which has all the property of a employee and
   all the set and get methods. This EmpForm also may has a colloection
   of EmpVO ( value object) fiels. This class extend ValidatorForm
   class and implement Iterator interface.

   Q. I still not sure, where should I store EmpVO, whether as a field
      in EmpForm or in Request object? Please advise here

2. Create a BaseAction class. Which extend the Action class and
   override the execute method. Based on a hidden field execute method
   call different methods (like for save or new or display). All these
   methods will be override in proper sub class.

3. Create a EmpAction class which extend BaseAction class. Override the
   required methods. Let’s say it override displayEmp method.
   DisplayEmp return a Collection of EmpVO.

       In DisplayEmp method we do  following things
         EmpBO empbo = new EmpBO()     // EmpBO is business delegates
         Collection empVO = empbo.getVO()

4. Create a class EmpDAOFactory to get the actual Implementation of
   BaseDAO interface using JNDI. It has a getDAO() function that will
   return EmpDAO.

    In the contructor of EmpBO
      EmpDAO empdao = EmpDAOFactory.getDAO()

    In getVO() function of EmpBO
       return empdao.DisplayEmp()


5. BaseDAO interface has all the functions related to user actions
   (like save,display,new..) and will be implemented by a every DB
   access related classes.


6. constructor of EmpDAO uses JNDI to get a instance of datastore using
   deployment descriptor.

      EmpDAO.DisplayEmp() function do following
          Get dbconnection
          Build and Execute sql
          Build EmpVO
          Close the dbconnection
          Return EmpVO

7. At this ponit control will go back to EmpAction class, and now
   EmpAction has Collection of EmpVO. Now we can either set this EMPVO
   to a filed in EmpForm or store it in Request object. ( I am not sure
   which one is better)


Your comments would be greatly appreciated. Please help me to build my first 
application.

Thanks





_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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

Reply via email to