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>

Reply via email to