struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: changing ActionForm to be a Java interface
Date Wed, 15 Jan 2003 04:58:14 GMT


On Tue, 14 Jan 2003, Hookom, Jacob John wrote:

> Date: Tue, 14 Jan 2003 22:24:22 -0600
> From: "Hookom, Jacob John" <hookomjj@uwec.edu>
> Reply-To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> To: Struts Users Mailing List <struts-user@jakarta.apache.org>
> Subject: RE: changing ActionForm to be a Java interface
>
> Is the resolution of this discussion that I shouldn't ever do something like this:
>
> public interface Employee extends Serializable
> public class EmployeeObject implements Employee
> public class EmployeeForm extends ActionForm implements Employee
>
> public ActionForward execute(.....) throws ......
> {
>      EmployeeForm empForm = (EmployeeForm) form;
>      Employee employee = new EmployeeObject();
>      BeanUtils.copyProperties(empForm, employee);
>
>      // persist employee object
> }
>

No, you're doing the reverse of what I would not want to see:

  public class EmployeeObject implements Employee, ActionForm

This is where you get into trouble over things like property types, as
well as making any user of EmployeeObject depend on Struts.

Your example correctly recognizes that EmployeeObject and EmployeeForm
are two totally differnt things, with different purposes and different
lifetimes.  And, note that neither Employee nor EmployeeForm have any
dependencies on Struts APIs, so they are reasonable to use in non-web
environments as well.

Craig


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


Mime
View raw message