Search code examples
spring-mvcviewspring-roo

Reusing other entity's view


I have 2 entities in my Spring Roo application, Experiment and Story. Experiment can contain several stories. I have already build a view for displaying a story.

Can I directly reuse that view to render the stories that are contained in an experiment's view? If yes, how to do it?


Solution

  • Taking a shot-in-the-dark, but I would say you could do something using JSP tags that look at some value, check the class type, and switch between displaying one Story or a list of Stories.

    Or, instead of that, you could make your Model value always be a List, and then just make your view JSP always loop the list, so if it gets a list of 1, it shows 1, a list of 10 would show the 10.

    Or, you could create a custom Dojo Widget. Have separate view (or do the above) and simply use the custom widget to display a single Story. Loop through the list, adding additional Widgets, you get a display of more than one.