Hi all,

I'm new to Wicket.
I'm building an application, actually finished most of the businness model
classes.
My businness classes don't have a default constructor, they have a
constructor with parameters. Inside the constructor, it calls to the
setters. These have the business rules implemented.

For example:
public User(String email, String name,
               String password, Date birth) throws BusinessException {
   setEmail(email);
   setName(name);
   setPassword(password);
   setBirth(birth);
}

public void setEmail(String email) throws BusinessException {
   testSetEmail(email);
   doSetEmail(email);
}

private void testSetEmail(String email) throws BusinessException {
   // Check the format and if it is wrong throw a BusinessException
}

private void doSetEmail(String email) {
   this.email = email;
}


Now, this is a trivial example, I have much more complex ones.
What I want to know is how should I use this kind of classes with Wicket.
I clearly cannot use the User object and a CompoundPropertyModel because I
don't have a default constructor.
So, should I use a UserDTO and a CompoundPropertyModel and have the
textfields in a form binded to it ? and then after the form is submitted
obtain the properties from the DTO and create the real User object? Of
course, I should try/catch the call to the constructor and if any exception
is thrown show that to the user in a feedback panel.

What do you think?

Thanks. 
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-Wicket-with-businness-model-classes-that-check-for-rules-tp3245298p3245298.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to