Announcement Announcement Module
Collapse
No announcement yet.
Possible to reuser a command object between submits? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible to reuser a command object between submits?

    Is it possible to reuse a command object between submits? I know that I can reuse a command object between the original GET and the subsequent POST (via the sessionForm bean attribute), but what I want to is reuse it between POSTs. The reason for this is because I have a paginated search page, whereby the search criteria appears above a paged table of results. When the user navigates between the result pages, I obviously don't want to requery the database. In order to achieve this I'm currently having to cache the results in the session once they've beeen retrieved, and then adding them to the new command object when the user navigated between pages.

    Nick
    Last edited by nickcodefresh; Aug 30th, 2006, 04:40 AM.

  • #2
    I would think carefully about caching data in the middle tier. By retrieving all the data once you have the following consequences:

    - DB is doing a lot of work loading all the rows (e.g. 32000)
    - network bandwith is increased
    - CPU is gobbled up while ORM tool rehydrates all those rows
    - memory footprint on the server is increased
    - data might be stale

    whereas if you query each time:

    - DB is only loading what it needs to satisfy each query (e.g. 10 rows)
    - server is stateless between requests (no server affinity etc.)
    - data cannot be stale

    Now, of course each request is going to make the DB do the "expensive" query, but that is what DBs are designed to do How many times do your users actually click through to the next page, then the next page etc.? For example, google often returns 100s of 1000s or rows, but I hardly ever go past page 2 or 3, so storing all that data on the server side is pointless.

    If your users *are* likely to hit page 2,3,4 etc. then maybe a better solution would be to send all the data to the client and use JavaScript to paginate it.

    Just my opinion, but in my experience it is always better to do the DB on every request.

    Comment


    • #3
      Ahhh good point, but I was actually simplifying my situation a little in order to make it easier to explain. What actually happens is that the search results is made up of two tabs. The first tab is the results, whist the second is a drill-down of more information regarding one of the result rows. Clicking on the second tab causes a database hit to get more information. After examining the drill-down the user will click back to the first tab. When clicking between these tabs I don't want to re-run the DB search. Hence I have to cache the current search results so that clicking between tabs is nice and fast.

      Hope this clears things up

      Nick

      Comment


      • #4
        Hi,
        By anychance do you have the solution for this issue,I am facing the similar scenario,where I want to come back to search result page from the details page.
        Any help would be appreciated.

        Thanks
        Shaiju

        Comment

        Working...
        X