Announcement Announcement Module
Collapse
No announcement yet.
Polymorphic views ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Polymorphic views ?

    Hi,

    I have a JSP that displays a list of objects of supertype Building as a result of a general query. The list includes buildings of many concrete types (ie House, Apartment, Office, etc - at least 20 possible types). If I click on any of the items in the list, I should go to the specific detail page for the particular type of building. I imagine that the request sends the buildingId as a parameter, and the Controller queries the database to pull up the object by its id.

    Two questions:
    1. Since I already got the objects and their data to populate the list, is there a way to use the clicked object to populate the View without making another query in the Controller ?

    2. Is there a reasonable way to know what kind of View to return without running endless instanceof's ?

    Thanks in advance,
    Jorge

  • #2
    1. Are you using Hibernate? If you can use the 2nd level cache, then querying for the building again will pull it out of memory. Otherwise, what approach are you using for accessing the DB?

    2. Can you make the view name, or part of the view name, a property of the building object? How many buildings require their own view or a shared view? All 20 of them?

    Comment


    • #3
      Originally posted by gmatthews
      1. Are you using Hibernate? If you can use the 2nd level cache, then querying for the building again will pull it out of memory. Otherwise, what approach are you using for accessing the DB?
      Yes, we are using Hibernate, but we hadn't gotten into caching strategies yet. Thanks to your suggestion we'll begin right away !


      Originally posted by gmatthews
      2. Can you make the view name, or part of the view name, a property of the building object? How many buildings require their own view or a shared view? All 20 of them?
      Since I posted, we've considered adding a static final String variable to each subclass which will become part of the detailed view name, as you suggested. Yes, every type of building requires its own view, since the properties vary.

      Thanks,
      Jorge

      Comment

      Working...
      X