In the example, the grid is loaded by calling a CFC that has remote
access, 'Users.cfc?method=getUsers'. The getUsers() method directly
queries the database for the data. To implement this in my application
I think I have a couple of options
1. Use a ColdSpring-generate remote proxy - Unlike the simple example,
I won't have a single CFC that hits the database to get the data.
There will be a userService.cfc which has an instance of a userDAO.cfc
(autowired by CS) that will grab this data. I can't hit the
userService.cfc directly because it wouldn't be initialized so that's
where the remote proxy comes in.
2. Make the call through fw1 - I would still have the userService.cfc
and userDAO.cfc but create an fw1 action that would return the data,
i.e. index.cfm?action=user.getUsers&returnformat=json.
Any thoughts on which approach might be better? I'm leaning towards
option 1.
-Phil
I strongly dislike pure data calls going through an MVC framework.
Barney Boisvert posted a good blog entry on this. Much better to hit a
CFC directly for pure data calls (and FW/1 supports that automatically
without you needing to do anything - just call the CFC from JavaScript
and FW/1 will get out of your way!).
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
--
You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com.
To unsubscribe from this group, send email to framework-on...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.
This is where AOP comes in, if you haven't already considered it. Your
proxy can expose your service code, at the same time intercepting
requests and adding calls to security and/or logging methods that are
already set up in your app. Similar to startXX and beforeXX I guess.
This can be done seamlessly so you never have to change your base
code. It is sweet when you set it up - you can add web services just
by using a naming convention and know that ancillary functions will
'just work'.
e.g. an aop proxy can add arguments to a function so all your web
service requests expect username/password even though your base code
does not.
Darren
On Mar 10, 7:50 am, Sean Corfield <seancorfi...@gmail.com> wrote:
> On Wed, Mar 3, 2010 at 10:50 AM, Phil Cruz <p...@philcruz.com> wrote:
>
> > Any thoughts on which approach might be better? I'm leaning towards
> > option 1.
>
> I strongly dislike pure data calls going through an MVC framework.
> Barney Boisvert posted a good blog entry on this. Much better to hit a
> CFC directly for pure data calls (and FW/1 supports that automatically
> without you needing to do anything - just call the CFC from JavaScript
> and FW/1 will get out of your way!).
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies US --http://getrailo.com/
> An Architect's View --http://corfield.org/
Oops! It was Brian Kotek, not Barney Boisvert:
http://www.briankotek.com/blog/index.cfm/2007/7/25/AJAX-Data-Requests-vs-AJAX-Content-Requests
> So if I hit a CFC directly, it does seems like I need to be using
> ColdSpring/remote proxy (because the actual service CFC will have
> dependencies) or am I over-complicating things? (I mean I could have a very
> simplistic CFC that returns data just like in the example, but in practice
> that's not the case).
You will need a remote proxy. I personally don't like the way
ColdSpring does this so I tend to handcode specific remote API CFCs
for my services as a whole (instead of the 1:1 mapping ColdSpring
creates).
It depends on what the requirements are for the remote API - that's
why I hand code them (and they're different for every project).
The general pattern of a remote API method is:
<cfset var fooService = application.beanFactory.getBean( 'fooService' ) />
<cfset var data = fooService.getSomeData( someArgs ) />
<!--- massage the data into the appropriate format for the remote API
result --->
<cfreturn massagedData />
For example, you might have a UserService that returns a User bean but
you might return just a struct from the remote API containing just id,
firstName, lastName.
jquery grid excerpt
url:'cfc/Http5.cfc?method=get&theUrl=#rc.sURL#&_cf_nodebug=true
When I make the call the request seems to run fine but in firebug I
see the following error.
Exception in
The action dashboard.index failed.
Element USERNAME is undefined in VARIABLES.
The default action controller/action in my application is
dashboard.index. How can I avoid this so that my call to the remote
method on my url just returns me data.
On Mar 10, 9:05 pm, Sean Corfield <seancorfi...@gmail.com> wrote:
> On Wed, Mar 10, 2010 at 3:59 PM, Judith Barnett <jmbarn...@gmail.com> wrote:
> > Do you have an example of this you could share?
>
> It depends on what the requirements are for the remote API - that's
> why I hand code them (and they're different for every project).
>
> The general pattern of a remote API method is:
>
> <cfset var fooService = application.beanFactory.getBean( 'fooService' ) />
> <cfset var data = fooService.getSomeData( someArgs ) />
> <!--- massage the data into the appropriate format for the remote API
> result --->
> <cfreturn massagedData />
>
> For example, you might have a UserService that returns a User bean but
> you might return just a struct from the remote API containing just id,
> firstName, lastName.
> --
> Sean A Corfield -- (904) 302-SEAN
> Railo Technologies US --http://getrailo.com/
> An Architect's View --http://corfield.org/
--
You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com.
To unsubscribe from this group, send email to framework-on...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.
FW/1's onRequestStart() method checks for invocations of .cfc files
and it deletes the onRequest() method specifically so that such
requests do not get intercepted.
Since you're on CF9 Dan, I wonder if it's something specific to that?
Nando, are you also on CF9?
What happens if you try to hit the CFC with that URL in your browser?
Sean
--
You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to framew...@googlegroups.com.
To unsubscribe from this group, send email to framework-on...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/framework-one?hl=en.
I am calling the method in the browser
http://localhost/dummy/cfc/http5.cfc?method=test
<cffunction access="remote" name="test">
<cfreturn "hello world">
</cffunction>
And when I run that I am seeing the component browser login, anyone
know why that is?
On Mar 18, 1:20 pm, Nando <d.na...@gmail.com> wrote:
> Sean, I'm on CF9 with this app and will try the remote example to try and
> narrow the problem down. It may be something else I'm running into
> specifically because I'm trying to upload a file via an Ajax-like method
> that uses an iframe to submit the request. I must admit I don't always fully
> understand what I'm doing ... :-)
>
> Nando
>
> On Thu, Mar 18, 2010 at 4:11 AM, Sean Corfield <seancorfi...@gmail.com>wrote:
>
>
>
>
>
> > I'm puzzled. This is a tested - and working - scenario as far as I can
> > tell. There's even an example of it that ships with FW/1 (the 'remote'
> > example: it has a remote access CFC which it calls as a Web Service,
> > via Flex Remoting and as a simple, in-browser invocation of the CFC
> > method directly - just as you are doing).
>
> > FW/1's onRequestStart() method checks for invocations of .cfc files
> > and it deletes the onRequest() method specifically so that such
> > requests do not get intercepted.
>
> > Since you're on CF9 Dan, I wonder if it's something specific to that?
> > Nando, are you also on CF9?
>
> > What happens if you try to hit the CFC with that URL in your browser?
>
> > Sean
>
> > On Tue, Mar 16, 2010 at 6:48 AM, Dan Vega <danv...@gmail.com> wrote:
> > > I have a similar problem. I am calling a cfc remote method directly in
> > > a view via javascript
>
> > > jquery grid excerpt
>
> > > url:'cfc/Http5.cfc?method=get&theUrl=#rc.sURL#&_cf_nodebug=true
>
> > > When I make the call the request seems to run fine but in firebug I
> > > see the following error.
>
> > > Exception in
>
> > > The action dashboard.index failed.
> > > Element USERNAME is undefined in VARIABLES.
>
> > > The default action controller/action in my application is
> > > dashboard.index. How can I avoid this so that my call to the remote
> > > method on my url just returns me data.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "framework-one" group.
> > To post to this group, send email to framew...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > framework-on...@googlegroups.com<framework-one%2Bunsubscribe@goog legroups.com>
So Ray gave me a great idea, add a log to the top of the cfc and write
out
<cflog file="extranet" text="#serializejson(url)#">
When I did this I saw
"Information","jrpp-363","03/18/10","14:49:34","EXTRANET","{""action"":""security.login""}"
A bell went off right away, on every request I was do a security check
// force login check if section is not security
if( request.section != "security"){
if( !structKeyExists(session,"isLoggedIn") || !session.isLoggedIn )
{
redirect("security.login");
}
}
So I just made a quick addition for any cfcs to get bpypassed
// force login check if section is not security
if( request.section != "security" && request.base != "/cfc/" ){
if( !structKeyExists(session,"isLoggedIn") || !session.isLoggedIn )
{
redirect("security.login");
}
}
Sorry for the posts on issues that were my fault :)
On Mar 18, 1:52 pm, Dan Vega <danv...@gmail.com> wrote:
Sean
i thought by calling the setBeanFactory() method in setupApplication i
would have access to the factory
in my remote facade.
can someone tell me the best way to gain access to this. should i add it
the application scope myself?
thanks
On 12/11/2010 12:06 AM, Sean Corfield wrote:
> On Fri, Dec 10, 2010 at 2:39 PM, Scott Conklin<socr...@sconklin.com> wrote:
>> 1) jquery grid tree:
>> -- call remote facade
>> "ajax" : {"url" : "/remote/userfacade.cfc?method=getUsers"}
> Yup. This is a data call so it should go direct to a CFC.
>
>> 2) remote/userfacade.cfc
>> 3) model/user/userService.cfc
> Yup.
>
>> b) if so, does best practice mean to have an xxFacade.cfc convention
>> for each service where necessary? or is there a better naming
>> convention?
> I tend to have a remote facade for the whole app or, if that's "too
> big", a remote facade for each "section" of the app.
>
>> c) does this belong in a "remote" dir like in the samples or could
>> this be in the model/user/ dir in this case or a services dir?
> The remote CFCs must be web accessible. Your service / model does not
> need to be.
>
>> d) i read that if wanted to invoke security, then i should pass
>> credentials on each call
> Generally, yes.
>
>> e) i have read AOP is the way to handle security in this scenario,
>> where is the best place to learn how to do this?
> Google Aspect Oriented Programming and read the ColdSpring documentation.
>
> Personally I'm not convinced that AOP is the best solution because I'm
> not convinced that auto-generated facades are the right solution. I
> generally find a custom, hand-written facade is a more appropriate
> solution - and that means custom security. But YMMV.
>
> There's no One True Way here. If your solution works for you - it's a
> solution and it's "right". No matter what solution you pick, there
> will _always_ be a "better" solution around the corner once you have
> new knowledge...
>
> (and you sent this direct to me, not to the list?)
Question: Since your remote proxy is "outside" FW/1, how would you
expect to access the object factory?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
> can someone tell me the best way to gain access to this. should i add it the
> application scope myself?
I would probably put it in application scope directly - and then call
setBeanFactory() to tell FW/1 about it.
(and that's the assumption ColdSpring makes about remote proxies, BTW,
so it's common practice).
--
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/