coldfusion - Using "var this" inside remote CFC methods -


I have inherited a project where several remote CFCs have been opened for some Ajax requests and inside < / Strong> Most of the CFCs have the following:

& lt; Cfset var. Response = true />

Now I've never used var and this has been used simultaneously in this way, so I'm not sure That's what to do about it, so I think my questions are:

Is there a problem with this code? If so, are they enough to give me all CFCs & lt; Cfset var req.response = true /> ?

I see that this is a quick example:

  & lt; Cfcomponent & gt; & Lt; Cffunction name = "check_foo" access = "remote" returnformat = "plain" & gt; & Lt; Cfargument name = "isfoo" type = "string" required = "false" default = "no" sign = "I check string for foo" /> & Lt; Cfscript & gt; / * Setup new response * / var this.response = false; Check for / * Foo * / if (! Findnocase ("foo", arguments.isfoo)) {/ * no foo! * / This.response = false; } Make this return. reaction; & Lt; / Cfscript & gt; & Lt; / Cffunction & gt; & Lt; / Cfcomponent & gt;   

.


Update:
  1. Based on feedback / answer, I have changed all the examples of the code I> it is . Thanks for everyone who helps you!


    using the code this is similar to using.

    Local area will also be included as a local variable in dumping as logic and this scopes (documented) Can not be done, but I get this result in bare CFCs, and you see it in my screenshot.)

    Because your function is access = "remote" On each call, a new example of CFC will be found, and therefore a bare this area is therefore "safe" But still there is a bad idea

    If any var is in non-remote jobs, you will be getting unwanted persistence and consequently the conditions are invalid data.

    The relevant CF document:

    ""

    ""

Comments