Results 1 to 3 of 3

Thread: Polymorphic views ?

  1. #1
    Join Date
    Oct 2005
    Location
    Bogota, Colombia
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    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?

  3. #3
    Join Date
    Oct 2005
    Location
    Bogota, Colombia
    Posts
    2

    Default

    Quote 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 !


    Quote 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

Similar Threads

  1. Replies: 22
    Last Post: Feb 4th, 2010, 01:37 AM
  2. Complex views
    By neunistivlija in forum Swing
    Replies: 0
    Last Post: Oct 17th, 2005, 03:27 AM
  3. Multiple views and pages question
    By jwray in forum Swing
    Replies: 3
    Last Post: Feb 19th, 2005, 09:22 AM
  4. Newbie question on Pages and Views
    By ragnarwestad in forum Swing
    Replies: 8
    Last Post: Dec 13th, 2004, 10:47 PM
  5. How to map views
    By pak in forum Web
    Replies: 4
    Last Post: Sep 8th, 2004, 02:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •