-
1. Re: Scope and Best Practices
fhh Apr 15, 2007 6:30 PM (in response to chubinator)
I can see how its not scalable to keep a large data model in memory for the duration of a user's session, but it seems equally non-scalable to query the database each time the user interacts with the page it supports.
I consider both bad practice. You should only fetch the data you actually need - not the whole data from the database. If you're resultset is large you should scroll over the resultset and fetch only the data actually displayed.
This is where converstations come in. You can have different subsets of a resultset to display in different windows. This is not possible with session scope as the results would overwrite each other.
The other advantage is that you can "clean out" the conversation context with a single annotation while you have to remove components from session scope explicitly.
However sometimes you do want that data is shared between different browser windows. This is were you have to use session scope.
I thought I'd ask the users how they use Scope?
IMHO it boils down to this: If your user is only using a single browser instance and you never and your long running converation performance will be exactly like using session scope. If your user uses multiple browser windows to access your application that do not share data you have to use conversations. If you end conversation now and then you will save memory compared to using session scope you do not clean. -
2. Re: Scope and Best Practices
pmuir Apr 15, 2007 6:52 PM (in response to chubinator)I used your questions to create a wiki entry - http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamScopeFAQ and merged in Felix's answers as well
-
3. Re: Scope and Best Practices
chubinator Apr 15, 2007 8:36 PM (in response to chubinator)Thank you for the prompt response and for the Wiki!
I've been working on a paging and sortable datatable view, but kept fumbling around with parameters (firstRow, noRows, sort column, etc) and how best to pass them around/scope them.
I landed on a temporary conversation and using page parameters for the parameters not explicitly used in the page (sort column). It seems to work, but was wondering if changing it to a long running conversation made more sense. But then I worried about the "lingering" conversation if the user navigated away in an unexpected way. As you said in the Wiki, perhaps its not worth worrying about since it will eventually time out.
I'll take a look at the Seam gen tool as suggested as well and see how does things.
Thanks again!