File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes FormBean[Struts] Vs ValueObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "FormBean[Struts] Vs ValueObject" Watch "FormBean[Struts] Vs ValueObject" New topic

FormBean[Struts] Vs ValueObject

wrushasen dakhane
Ranch Hand

Joined: Sep 25, 2006
Posts: 47

Please tell me what is the difference between FormBeans in Struts and ValueObject design pattern.


SCJP 1.4, SCWCD 1.4
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
I know very little of Struts however you may want to clarify whether you are referring to the Value Object (P of EAA) pattern, or the Value Object (J2EE) pattern which has been renamed to Transfer Object (J2EE), which is more generally referred to as the Data Transfer Object (P of EAA) pattern.

Value Object (VO) vs. Transfer Object (TO) vs. Data Transfer Object (DTO)
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
Upon cursory inspection I would suspect that the motivation behind the design of the Struts Form Bean is different from the motivation behind the Data Transfer Object.

The motivation behind the Data Transfer Object is to create a serializable data container that can help move data across JVM, process and network boundaries. It often carries more data than is required by the caller and is usually devoid of any behavior besides what is necessary to set and get its data members.

A Form Bean can add validation behavior. Being a Java bean means that it has an easily discoverable interface that is easy to configure (and load) declaratively through configuration files (rather than programmatically through program code). It's primary purpose seems to be an abstraction/container for form data, to serve as a parameter to an object modeled after the Command pattern (the Action). The Form Bean is serializable but I'm not sure how essential that is to the primary purpose of the Form Bean - I don't believe that the Action consuming the Form Bean is likely to be in a different JVM from the one where the Form Bean was created in the first place.

It would be incorrect to assume that designs and/or patterns that lead to similar looking implementations "are the same" when in fact the driving motivations are different.
[ March 28, 2007: Message edited by: Peer Reynders ]
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
What Peer said.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: FormBean[Struts] Vs ValueObject
It's not a secret anymore!