On Friday, Feb 21, 2003, at 15:07 US/Pacific, Barney Boisvert wrote:
> It seems it would be an amazingly trivial thing to incorporate,
> assuming
> that CF variables are accessible from the Java size of things in a
> consistent (and documented) manner. Haven't looked at the .java files
> much,
> so I don't know how they all work. Perhaps Sean or Christian could
> comment?
The key point here is "assuming that CF variables are accessible from
the Java size of things"... Java is case-sensitive, CFML is not. That
alone introduces some interesting issues:
<%
x = 1;
X = 2;
%>
<cfoutput>#x# #X#</cfoutput>
In CFML, #x# and #X# refer to the same variable but in the JSP
fragment, they refer to separate variables.
There's also some scoping issues - CFML's scope model is very different
to Java's. When you refer to #x# it could be in (pretty much) any scope
in CFML. A variable reference in Java has a very different set of rules
governing which 'scopes' are searched (and several of the CFML scopes
don't exist in Java).
This could be solved by providing appropriate proxy objects in Java
through which you could access CFML variables, but you'd need some
fairly ugly syntax in JSP to do things like assignment:
<%
CFMLassign("x",1);
X = CFMLvalueOf("x");
%>
The first line would assign to a CFML variable as if you said:
<cfset x = "1">
The second line would assign to the Java variable 'X' (uppercase) the
current value of CFML's 'x' (case insensitive).
I hope you can see why this would soon become unpleasant.
>>> <cfscript>
>>> missing = createObject("java", "java.util.ArrayList");
>>> missing.init(request.neededfilenames.clone());
>>> missing.removeAll(request.foundfilenames);
>>> createObject("java", "java.util.Collections").sort(missing);
>>> </cfscript>
>>>
>>> Rather than something like this, which is far easier to read:
>>>
>>> <%
>>> missing = new
>>> java.util.ArrayList(request.neededfilenames.clone());
>>> missing.removeAll(request.foundfilenames);
>>> java.util.Collections.sort(missing);
>>> %>
I'm not sure I'd agree with *far* easier to read but I do agree it is
*slightly* easier to read. You can certainly mitigate the difference
with a suitable UDF, e.g.,
<cfscript>
missing = jnew("java.util.ArrayList",request.neededfilenames.clone());
missing.removeAll(request.foundfilenames);
jnew("java.util.Collections").sort(missing);
</cfscript>
However, it wouldn't hurt to 'vote' for easier Java integration using
the wish form on mm.com (the URL of which escapes me, since I'm on
BART, but is posted here fairly regularly).
Sean A Corfield -- Director, Architecture
Web Technology Group -- Macromedia, Inc.
tel: (415) 252-2287 -- cell: (415) 717-8473
aim/iChat: seancorfield -- http://www.macromedia.com
An Architect's View -- http://www.macromedia.com/go/arch_blog
Announcing Macromedia DevNet Subscriptions
Maximize your power with our new premium software subscription
Find out more: http://www.macromedia.com/go/devnetsubs
�
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4