How to separate the model object for view and domain entity object for database in Spring Roo?

303 Views Asked by At

Often, I can not use the @RooMongoEntity entity class as a view model directly, for example:

// domain entity
@RooJavaBean
@RooToString
@RooMongoEntity
public class CouponItem {

    @NotNull
    private String contentId;

    private String title;

    private String description;

    private String detailUrl;

    private String detailPage;

    @RooUploadedFile(contentType = "image/jpeg")
    @Lob
    private byte[] picture;

}

but I need another bean for view layer:

// bean for view layer
public class CouponDoItem {
    private String id;
    private String contentId;
    private String title;
    private String description;
    private String pictureUrl;
    private String detailUrl;
}

so, How to generate the view pages (list.jspx, create.jspx, show.jspx, update.jspx) for CouponDoItem bean?

1

There are 1 best solutions below

0
On

Create the web layer for CouponItem entity and customize it to use CouponDoItem.

You can customize it by pushing-in generated Spring MVC controller methods for the CouponItem entity and modifying them as needed.