Hi,

I suggest to not duplicate variables that are in your Value Objects in your 
form object.  Instead include the value object as a member of the the form 
object.

ie.

Form class - below the AccountVo is a value object within the form bean

public class AddAccountForm extends ActionForm {
....

  public AccountVo getAccount() {
        return account;
  }

  public void setAccount(AccountVo aAccount) {
        account = aAccount;
  }

....
}

Then, in your jsp you reference the accountvo members like so using the dot 
notation -- the property "account.password" gets converted to 
getAccount().getPassword() or getAccount().setPassword(value).

<strutshtml:password property="account.password" size="30" maxlength="10" />
<strutshtml:text property="account.accountName" testexpr="eMail"  size="60" 
maxlength="100" />


This feature of struts/javabeans is a real time saver in terms of 
development.  Once something is in a value object then that value object 
gets passed from the back-end all the way to the front end without needing 
to touch any of it's attributes.  And if you're editing the data on a web 
page when you submit the page the new data automatically gets set into the 
value object which can then be passed to the back end (no unnecessary 
handling of the data).

HTH,
Michelle

>From: "Sobkowski, Andrej" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: Design question - Action Form vs Business Delegates/Value Objects
>Date: Thu, 22 Nov 2001 13:28:05 -0500
>
>Hello,
>
>we're working on a quite large project with J2EE (including EJBs) and we're
>using Struts (we're still in the early phases). To design a "clean"
>application, I've defined different "object conversions":
>* Request phase
>- the ActionForm is converted to a Value Object
>- the Value Object is passed to the EJBs
>* Response phase
>- the EJBs return one ore more Value Objects
>- the Value Object(s) is (are) converted back to ActionForms.
>
>I think it's a good approach, but:
>- my ActionForm and Value Objects have an almost identical interface. The
>main difference is that the ActionForm instance variables are always of 
>type
>String while for the Value Object  have "final types" information (Date,
>Integer, whatever)
>- the conversion "ActionForm to VO" and back is slowing down the 
>performance
>as my EJBs often return hundreds of VOs (each one to be converted to an
>ActionForm).
>I know this can be improved by using paging (Page-by-Page iterator) on both
>the back-end and the front-end; furthermore, I've written a small "mapper"
>that uses extensively the Reflection API to automatically perform the
>mapping and this probably has an impact on the overall performance.
>
>My question is: what are the best practices for this type of issues? Does
>anybody have the same problems? Should I reduce the level of abstraction
>between the layers?
>
>Thank you!
>
>Andrej
>
>PS. if you're interested, I can share the simple mapper. It's a very small
>mapper (less than 15k) that works fine with my app. It's waaaaaaay less
>complete than the mapper on Ted Husted's site but...
>
>-----Original Message-----
>From: Jon.Ridgway [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, November 22, 2001 12:10 PM
>To: 'Struts Users Mailing List'
>Subject: RE: design question
>
>
>
>
>-----Original Message-----
>From: M`ris Orbid`ns [mailto:[EMAIL PROTECTED]]
>Sent: 22 November 2001 16:54
>To: Struts-list (E-mail)
>Subject: design question
>
>Hello
>
>I have several questions about design, "best practises":
>
>1)  Where to store client's profile information (like login name) ?
>session  or system state bean ?
>
>Use the HttpSession. But be aware that you should put as little as possible
>into the session. Large sessions do not work well in a cluster.
>
>2)  How to create and use a system state bean ?
>
>System state bean should be in scope "session", shouldnt it ?
>
>Again put as little as possible in the session and avoid statefull session
>beans. If you must put a bean in the session, make it as small as possible,
>ideally it would just hold key info that can be used to request beans at
>request level when needed. This is a trade off between performance and
>scalability.
>
>3) Where to put business logic (where I invoke JDBC) ?
>       Should business logic class be a bean ?
>
>If you have an app server business logic should go into a stateless session
>bean (BusinessService), which is invoked (via a BusinessDelegate) from a
>struts Action class. If you are not using EJBs then the Action class should
>still invoke a business delegate, but the delegate would simply create a
>normal Java bean to act as the Business Service. The business service
>(Stateless EJB or Java Bean) should delegate to another class to access a
>datasource. If your are using EJBs this should be a CMP or BMP+DAO 
>depending
>on your app server (EJB 2 compliant consider CMP, else try CMP if supported
>but be prepared to subclass to a BMP+DAO at a later date).
>
>thanx in advance
>Maris Orbidans
>
>
>Jon Ridgway.
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>


_________________________________________________________________
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