With MVC, the idea is that the controller handles the events (by
talking to your model, hopefully), vs. spreading your event logic
throughout your app (like in your views).
Seems sorta like it should be MCV, neh?
At least that's my [limited] understanding of the pattern.
The most a view should do would have a link to the event, not run the
event itself (the controller should have done that, if it was needed).
I think. :)
--
We can recognize the dawn and the decline of love by the uneasiness we
feel when alone together.
Jean de la Bruyere
In the real world, sometimes we can't avoid doing "bad things" for
"good performance" reasons, but what you're suggesting really seems
like it should be doable within the MVC pattern.
Since you can "stack" views, how about caching the ones that don't
change, and not caching the ones that do?
I'm thinking there's a way to do the thing you're asking about without
mixing controller logic into your view, but I'm not completely sure
without a use-case.
Can you give us a little real-world walk-through of what you are
trying to accomplish?
--
The world is not comprehensible, but it is embraceable: through the
embracing of one of its beings.
Martin Buber
As am I! If it were an incredibly big limitation, you'd think many,
many other people would have run into it. ;)
> I cannot believe there is no way to call an Event-Handler outside the
> implicit event invocation.
There is always a way, but the why is generally more important.
I don't see anything in your use-case that suggests what you want to
achieve can only be (or in face, should be) done in the view.
But FWIW: Have you looked at the RemotingService stuff? Using MG with
Flash, etc.?
On the reals tho, I think you haven't quite wrapped your head around
the MVC pattern (it's cool, neither have I).
Portlets don't seem to be "views firing events" (as far as I can
tell)-- check out the JSR:
http://jcp.org/en/jsr/detail?id=168
For the caching, sounds like you want to put a lot of stuff in each
session? Lots of per-session caching seems kind of hard to scale out,
but I'm no expert.
Let's see if we can't come up with a real world, MG-style solution for
your real-world example! I'm hot to try out the caching stuff too,
right after I finish some play with Scaffolds.
:DeN*
--
To be old can be glorious if one has not unlearned how to begin.
Martin Buber
I was just saying that it seems (to me, Read: not an expert) that if
you store a lot of info in the session, you've got to replicate that
info , right? Maybe I'm wrong, and there's no more overhead to
replicating session data than say, application data-- from my limited
exploration of caching, that doesn't seem to be the case, but I'm
always 100% capable of being quite wrong.
> 2) We are not talking of breaking MVC pattern. MVC pattern do not tell
> you from which layer
> an event can be invoked. What MG doeas is to adapt an MVC pattern
> to an url call.....that's it.
Yes, it's beautifully uncomplicated, isn't it?
> I will try again and I will let it go....
I'm not meaning to frustrate you. There is a little communication
barrier to deal with, nothing we can't handle.
> I want to cache a view ok??
> This view needs data to produce an output ok???
With you so far...
> I run my event first time.
> Controller is fired and make logic for preparing data.
> The views receives data make html and cache itself.
Alright...
> I recall the event.
> The view is cached so do not need data but ..... controller is fired
> in any case.
>
> Is that right???
> Is that efficient to you???
In an MVC pattern, I'd always expect the controller to be involved
between my model and my view, so I'm not quite following you here.
Are you suggesting that the view take over some (all?) of the
controller's responsibilities?
You want the view to handle cache control? If you "set it and forget
it", why not go the dynamic to static content route, and leave the
appserver out of the picture? The webserver itself can cache and
serve out requests at some pretty impressive speeds...
I guess what I'm not getting is how moving controller logic into a
view makes caching easier/more robust.
If I was going to get heavy into caching, I'd be doing the lion's
share in my model, versus a non-agnostic location, such as MG.
I love my MG stuff to be simple. I dislike how easy it is to start
putting logic in controllers, or views, compared to in the model,
where (IMHO) it belongs. So I think I'm a little biased, and probably
come off as such.
I always try to think (even tho I don't have to, really) "how would I
use this same code in mach-ii or fusebox?", and similar thoughts.
Heck, I like "helpers", but I know that when I rely on them, I'm
relying on MG (which is fine, as I said, since I use MG, and don't
really foresee moving frameworks-- but still. =])
Eh. I'm sorta wandering now, so I'll shut up. Sorry if I put you off
with my demeanor. It just seemed that what you wanted was something I
rail against in general. *blush*
--
Dignity belongs to the conquered.
Kenneth Burke