+1

Although it may seem like splitting hairs because (in your case) the same 
object instance is passed to the doBusiness method, there's a huge 
architectural/design difference between:

public class myModel {
  public void doBusiness(DynaActionForm data) {
  ...
  }
}

and:

public class myModel {
  public void doBusiness(DynaBean data) {
  ...
  }
}

I suppose another possibility would be to use BeanUtils.describe or 
PropertyUtils.describe (not sure which is preferred) to generate a Map to pass 
to the doBusiness method. Either describe method can deal with a DynaBean.

Quoting Robert Taylor <[EMAIL PROTECTED]>:

> I would say you wouldn't necessarily violate MVC if you pass the
> DynaActionForm as a DynaBean into your model. Your model doesn't need
> an "Form" functionality, it only needs to access the data which is
> supported
> by the DynaBean contract. DynaBean is not bound to any presentation layer
> and
> therefore does not couple your business tier to your web tier.
> 
> When passing data from my web tier to the business tier, I tend to convert
> the data contained in the form into data structures native to the business
> tier;
> Data Transport Objects (DTO) sometimes refered to as ValueObjects. I then
> pass
> around these DTOs.
> 
> There has been plenty of discussion on this list and depending on which
> engineer
> you speak with you may get a different answer. For more information on
> this,
> search
> the archives.
> 
> HTH,
> 
> robert
> 
> > -----Original Message-----
> > From: Vincent Stoessel [mailto:vincent@;xaymaca.com]
> > Sent: Tuesday, November 05, 2002 2:34 PM
> > To: Struts Users
> > Subject: Passing an (Dyna)ActionForm to the business object
> >
> >
> > I know I have probably violated MVC by doing this but
> > while trying to find an elegant solution to passing
> > field values between my Action classes and my Model Classes
> > I went ahead and passed the whole darn DyaActionForm (daf)
> > to my Model class:
> >
> > Why did I got to the dark side? It was so convenient to
> > only have to add/remove fields in one class (and in struts-config.xml).
> > I am working with a massive form that is in flux and editing 2 classes
> > all the time was slowing me down:
> >
> > // The Old way: the force
> > in myAction:
> >
> >      DynaActionForm daf  = (DynaActionForm) acForm  ;
> >      myModel mym  = new myModel();
> >         String firstname = (String) daf.get("fname");
> >         String lastname = (String) daf.get("lname") ;
> >         String street = (String)daf.get("street") ;
> >         String city = (String)daf.get("city") ;
> >         String state = (String)daf.get("state") ;
> >
> > myModel.doBusiness(firstname, lastname,street,city,state);
> >
> >
> >
> >
> > then in myModel:
> >
> > PreparedStatement   pstmt  = con.prepareStatement(qstr);
> >              pstmt.setString(1,(String)daf.get("firstname"));
> >              pstmt.setString(2,(String)daf.get("lastname"));
> >              pstmt.setString(3,(String)daf.get("street"));
> >              pstmt.setString(4, (String)daf.get("city"));
> >              pstmt.setString(5, (String)daf.get("state"));
> >
> >
> >
> > // the New Way: the dark side
> >
> > now I can just do:
> >
> > myModel mym  = new myModel();
> > myModel.doBusiness(daf);
> >
> >
> > Yes, in myModel class  I still have to break out daf.getXXX but at least
> > now all thefields can be managed from one place and less prone to
> > mismached case/spelling (for me anyway) than it was before.
> >
> > Of course I really do not want to violate the Struts MVC model, is there
> > a better way than the first method?
> >
> > Thanks All
> >
> >
> > --
> > Vincent Stoessel
> > Linux Systems Developer
> > vincent xaymaca.com
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@;jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@;jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@;dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to