I found that as soon as your web model begins to diverge from your business level in function, it is best to use a presentation-level object (model object) to collect or display data
an object:
public class com.myapp.domain.UserEntity { }
model object:
public class com.myapp.somesite.web.SomeSiteUserModel { public static SomeSiteUserModel from(UserEntity userEntity) { ... initialize model ... } public UserEntity getModelObject() { ... get entity back ... } }
now all operations based on the view can transfer processing to the internal object of the model, if that makes sense, otherwise it can configure them independently. Of course, the problem is that you have to rewrite all the recipients and setters that you want for the object (the problem I had to deal with is annoying), unfortunately this is a Java language problem
source share