Announcement Announcement Module
Collapse
No announcement yet.
Are you creating xxxForm classes or using 'model' classes? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment

    Working...
    X