Hello Jan,
what I've used (tell me if it sucks) is via dictionary adapter and a
base controller:
protected TInterface
getDictionaryAdapter<TInterface>(IDictionary
dictionary) {
var adapter =
DictionaryAdapterFactory.GetAdapter<TInterface>
(dictionary);
// check if it's base viewmodel and if dictionary is
PropertyBag
if(typeof(IBaseViewModel).IsAssignableFrom(typeof(TInterface)) &&
dictionary == PropertyBag)
{
// do something clever here
(adapter as IBaseViewModel).MenuItems =
getMenuItems();
(adapter as
IBaseViewModel).ClientSideDateFormat = "dd/mm/yy";
}
return adapter;
}
here if I recognize that property bag is being populated and it
implement a specific interface, I set the properties for use (often in
the layout)
In your ajax action you won't need to use this method so it doesn't
populate anything.
I think this can be decoupled a bit but it gives an idea to achieve
what you want
On Dec 8, 11: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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---