Jan - it's not that you are not *allowed* to do actual logic within ViewComponents. it's just not recommended. imo, all of the actual logic must be concluded within the bounds of the controller's (action + filters). once execution is handled to the ViewEngine, only UI logic should happen - that is _for_ and _if_ constructs.
you _can_ decide otherwise, but I'd use a Filter for that instead. On Tue, Dec 9, 2008 at 8:17 AM, Mike Nichols <[EMAIL PROTECTED]>wrote: > > When I have data that needs to be 'on every page' I typically either > look at loading the data from a controller on page load (ajax) or if > it want it to participate in the rest of the load I push into a view > component....I use services in view components when I want > to...WindsorIntegration is builtin to accommodate. > But if I want to subclass behavior based on the context of, say, some > state on the controller, I push into a dynamic action and either put > it on my base controller or just the ones that should consume it. > > > On Dec 8, 3:56 pm, "Jan Limpens" <[EMAIL PROTECTED]> wrote: > > Hm, dunno, does not look filterish to me. But you are right, maybe... > > > > Is there a good reason why it is not recommended to pass a service to > > a view component? > > This would be by far the easyest solution. > > I remember, a long time ago, I read, that purely the controller should > > have access to the service/data layer, but I wonder if this is not > > just a dogma... > > > > > > > > On Mon, Dec 8, 2008 at 8:51 PM, Colin Ramsay <[EMAIL PROTECTED]> > wrote: > > > > > A filter? > > > > > On Mon, Dec 8, 2008 at 10:44 PM, Jan Limpens <[EMAIL PROTECTED]> > wrote: > > > > >> Hello, > > > > >> for MR > > >> on a project, I have a BaseController and on it's Initialize method, I > > >> used to pull some data I used on every page. That was nice for a > > >> while, but recently I started to return a lot of Json and of course > > >> base.Initialize fires and does a lot of stuff that has nothing to do > > >> with the json requests. > > > > >> Now, I could separate json and layout methods via different > > >> controllers, but this would lead to a lot of code repetition. I would > > >> like to avoid to have a AddressController and another > > >> AddressJSONController because they shared too much and I could not > > >> even use inheritance. > > > > >> Now I *could* grab this data only when there is Layout. Is there some > > >> kind of hook, I can use to put the data into the propertybag based on > > >> this assumption? This would have to happen after the Action completed, > > >> but before data is passed to the view engine. Is there something? > > > > >> -- > > >> Jan > > > > -- > > Jan > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
