Hi Aaron, To take a slightly different tack: Q1: - You don't want to track this in view as responsibility of view is to display state - not to change it (by recording an updated number of views) - If you ever added an AJAX or Flex or web service front end, would you want to keep track of number of those views as well? If so (which would make sense for most use cases) you want to add this to your model - not your (HTML specific) controller. - As to where to put this in the controller, I'd put it into your service objects (or managers if that is what you call them). Why? Well, some time you might add caching so you don't always return to the db, so the DAO/Gateway is probably the wrong place, but you always have to ask the UserService to get a list of users or ProductService to get a list of products, so add the code there.
If you want to be really fancy and are using ColdSpring, you could use AOP to pull the logging code out of your service methods and add it as a piece of advice before, after or around the appropriate method calls. That would be the cleanest solution for a large project, but if I could recommend expediency over elegance, stick it in your service methods and it'll be fairly easy to refactor out elsewhere. AOP is one extra thing you don't need to figure out today. As for Q2, stick the data into a session variable. The biggest question is what should stick the data into the session variable. The view doesn't as it displays state - it doesn't change it (by recording within the session what this person has viewed). Then ask whether if you were using Flex front end you'd want this to still work. If so, it can't go in your (HTML specific) controller, so put it in your model. It IS OK for your model to be session aware as long as you distinguish the different uses of session state (on my list of things to blog about) and allow the appropriate uses to be handled by model and controller respectively. You MAY want to use a session façade as it will help if you ever change the way you implement session state, but the debate as to whether to use scope facades is still open - Doug Hughes posted about this some time back on his blog. If you don't know what a session façade is, just stick this in the model to start with and you can always refactor to a session façade down the line. If you get the big architectural choices right upfront, tweaking the smaller ones down the line is a good approach to avoid overthinking things. Best Wishes, Peter On 12/21/06 5:18 PM, "Aaron Roberson" <[EMAIL PROTECTED]> wrote: > FIRST Q: My current application tracks who many times an individual > record is viewed by incrementing a value each time it is queried. How > would I do this in a MVC app, given that an individual record could be > queried for display in a view or for editing in a form? > > SECOND Q: How do I track what records a user has viewed during a > session (such as a product - like how Amazon displays items you have > viewed)? > > Thanks for any tips or references, > Aaron > > > You are subscribed to cfcdev. To unsubscribe, please follow the instructions > at http://www.cfczone.org/listserv.cfm > > CFCDev is supported by: > Katapult Media, Inc. > We are cool code geeks looking for fun projects to rock! > www.katapultmedia.com > > An archive of the CFCDev list is available at > www.mail-archive.com/cfcdev@cfczone.org > You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org