coldfusion - How to ensure a cfobject variable is local to a function? -


assuming following code in regular .cfm file, not cfc:

<cffunction name="myfunction"> <cfobject type="java" action="create" class="path.to.my.java.class" name="myjavavariable"> </cffunction>

what going scope of created object? i'm getting feeling it's not limited function scope. if so, how make local? following work?

<cfset var myjavavariable = ""> <cfobject ... name="myjavavariable">

edit: forgot under coldfusion mx 7, prevent useful solutions found on web working.

i did find workaround 1 creates fake local scope (<cfset var local = structnew()>). work such tags since can put return variable local.somevar.

i'd question why you're using <cfobject> @ all, rather more obvious simple assignment:

var myjavavariable = createobject("java", "path.to.my.java.class"); 

isn't more natural code anyhow?


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -