"service" is a method in the framework, not in your controller. I
suspect you're also looking at the wrong line of the stack trace and
that there is another stack trace line that refers to your controller
component.
Ryan
> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
>
> FW/1 on github: http://github.com/seancorfield/fw1
>
> FW/1 on Google Groups: http://groups.google.com/group/framework-one
>
What Ryan said - but also: redirect() does an *immediate* redirect so
no queued services would be executed.
If you want services to run first, you'd need to do this:
function startDoLogoff(rc){
variables.fw.service('user.RemoveUserSession');
}
... services run now ...
function endDoLogoff(rc){
variables.fw.redirect('security');
}
The start/end pair of controller methods wraps the service calls.
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
In theory I could auto-inject the framework's API into your
controller's variables scope but that might conflict with your own
methods...
NP. That's what we're all here for - to stop tail-chasing early :)
function startDoLogoff(rc){ variables.fw.service('user.RemoveUserSession'); } ... services run now ...
function doLogoff(rc){ what goes on here; when does it get called? do i need this? what would it be useful for? }
function endDoLogoff(rc){ variables.fw.redirect('security'); }
variables.fw.service('user.RemoveUserSession');
variables.fw.redirect('security');
--
What Ryan said - but also: redirect() does an *immediate* redirect so no queued services would be executed.
function startDoLogoff(rc){ variables.fw.service('user.RemoveUserSession'); }
function doLogoff(rc){
what goes on here; when does it get called? do i need this? what would it be useful for? }
... services run now ...function endDoLogoff(rc){ variables.fw.redirect('security'); }
function doLogoff(rc){variables.fw.service('user.RemoveUserSession');
variables.fw.redirect('security');}
--
function DoLogoff(rc){ variables.fw.service('user.RemoveUserSession'); }
... services run now ...function endDoLogoff(rc){ variables.fw.redirect('security'); }
Ryan
ok, but defining it is optional. so it can be left out.
if i were to define doLogoff(rc) what would be something that i could do in there? if i needed to do more than i did in startdoLogooff?
that means i could do this as well? (seems weird to conceive a controller method name and not use it's actual name anywhere)
The intended usage is _either_:
function startSomeAction(rc){
... do stuff including queuing up services ...
}
... services run here ...
function endSomeAction(rc){
... do stuff with the results of services and/or do redirects ...
}
_or_ this:
function someAction(rc){
... do stuff including queuing up services ...
}
... services run here ...
start/end indicates you are wrapping service calls. The plain
controller action indicates you are not wrapping service calls.
I've talked a couple of times about changing the flow so if startXyz()
is present, xyz() would not be called - and similiarly if startXyz()
was not present, endXyz() would not be called. This would enforce the
style I would prefer people to follow.
But I suspect it would break some existing applications :)
However, since I'm going to change the default behavior for services
in 2.0, I may well change this behavior too (and provide a backward
compatibility flag).
Sean
>> However, since I'm going to change the default behavior for services in 2.0, I may well change this behavior too (and provide a backward compatibility flag).
Currently, FW/1 implicitly queues up a service call matching
section.item - in addition to any you queue up yourself. In release
1.2 there is a framework setting - suppressImplicitService - that
let's you turn that behavior off. In 2.0, that setting will default to
true (instead of false in 1.2) so the implicit queuing will not
happen, but you will be able to set it true to enable the
1.2-compatible behavior.
If you want more background, this was discussed in a thread a while
back so I can dig it up for you - and it was also discussed in depth
in the CFUnited BOF session and the proposed change in 2.0 was the
consensus of the FW/1 users present.
> i actually just saw in the samples where there was an implicit service call
> service.someaction() and a matching endSomaction(rc) in the controller
> that is the recipient of rc.data
Yes, I need to update those examples - they don't always follow FW/1
"best practices" because, well, we've evolved the best practices over
time and many of the examples predate current thinking :)
> I sort of liked this flexibility and was actually planning to adopt this
> style of operation for quite a few of my
> controller/service calls. should i not if this is going to change? would
> this no longer be best practice?
Which specific "flexibility"? I think using either the startItem() /
endItem() pair together or just the item() solo method is a reasonable
convention and would encourage everyone to follow that rather than
the, to me, rather weird item() / endItem() pair... 'end' without
'start' just seems... untidy :/
If you want more background, this was discussed in a thread a while back so I can dig it up for you - and it was also discussed in depth in the CFUnited BOF session and the proposed change in 2.0 was the consensus of the FW/1 users present.
Which specific "flexibility"? I think using either the startItem() / endItem() pair together or just the item() solo method is a reasonable convention and would encourage everyone to follow that rather than the, to me, rather weird item() / endItem() pair... 'end' without 'start' just seems... untidy :/
I don't have a problem with having just endItem() in the controller
and relying on the implicit service call being queued up (and in 2.0
you'd need to set suppressImplicitService = true to do this).
My objection is to the inconsistency of having item() / endItem()
rather than startItem() / endItem().
Any controller method can be omitted if it would be empty.