Hi everyone. I have a general question about using the ActionForm beans 
with regular javabeans. As my understanding goes, the ActionForm beans can 
be populated automatically after the user submits that form. Now that the 
ActionForm bean is populated, it runs the appropiate Action. So in this 
action, I want to translate a ActionForm bean to a regular javabean. This is 
because I read that the ActionForm bean is tied more to the view then the 
model. Once I have this javabean, I'll use it to update/add/modify/delete a 
Person in the db. Unfortunately the two beans' properties match one-to-one. 
Like maybe for example both have these method prototypes:

public String getName()

public setName(String name)

  So my question (finally) is where should I convert these Form beans to my 
state beans? I thought of either doing it one of two ways:

1)in the Action class...

    ...
    PersonBean person = new PersonBean();
    person.setUsername(form.getUsername());

    //use person object to do something (save in session, update db,etc)

2)in the PersonBean class...

    public static PersonBean convert(ActionForm form) {
      PersonBean person = new PersonBean();
      person.setUsername(form.getUsername());
      return person;
    }

  and do this in the Action class...

    ...
    PersonBean person = PersonBean.convert(form);
    //use person object to do something (save in session, update db,etc)

=============

   With one property, it seems sort of trivial. But with a dozen or so, it 
can really clutter the Action class in option 1). Well if you guys have any 
insights on this, I'll be really appreciative. Thanks in advance!


--Davin

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

Reply via email to