Results 1 to 2 of 2

Thread: Are you creating xxxForm classes or using 'model' classes?

  1. #1
    Join Date
    May 2005
    Location
    BEEK, The Netherlands
    Posts
    230

    Default Are you creating xxxForm classes or using 'model' classes?

    Hi,

    I'm wondering how other people are using the command classes most effective.

    Imagine this 'model' class:
    my.company.model.bean.Person {
    String username;
    String password;
    String firstname;
    String lastname;
    String activated;
    }

    This class is also uses to to store the information. E.g. something like hibernate.persist(Person person).

    On a page registering persons I can use this 'model' bean as command class. So i don't need to write a PersonForm class.
    Is this a good approach?

    Further when I have login page, the user only enters the usrename and password. I can still use this Person class inseat of creating a LoginForm containing only the username and password.

    However there might be a problem when having a change password page,
    in which the user has to enter the old, new and retyped password. In this case the Person class is not sufficient and I have to create a ChangePasswordForm.
    The problem is now I'm mixing specific Form beans and 'model' classes.

    Regards,
    Marcel

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    On a page registering persons I can use this 'model' bean as command class. So i don't need to write a PersonForm class.
    Is this a good approach?
    Yes. Spring MVC was written to assist with this kind of approach. (PS - should activated be boolean).

    I can still use this Person class inseat of creating a LoginForm
    You can also use a MultiActionController with no form object. It may not be good idea to have a partially populated object.

    In this case the Person class is not sufficient and I have to create a ChangePasswordForm.
    The problem is now I'm mixing specific Form beans and 'model' classes
    That's perfectly valid. Don't try to fit the model where it doesn't belong.

Similar Threads

  1. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  2. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  3. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM
  4. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM
  5. Content Provider vs View Model
    By Martin Kersten in forum Swing
    Replies: 21
    Last Post: Mar 10th, 2005, 02:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •