PDA

View Full Version : Java integration


jmcclain
08-22-2005, 11:17 AM
Wouldn't it be GREAT to be able to use java instead of javascript (or have an option) for methods/scripts/constraints? I would love to be able to have a java based rules engine (drools) on the client, access the jar, then be able to process field rules for an application on the client side via. Validation would be more efficient, screen redering code would be so much easier to write as field properties/values could be modified based on business rules attached to each field.

Is tehre any plan to incorporate java into LZX?

hqm
08-22-2005, 11:26 AM
The way that would happen would have to be a port of the runtime library (LFC) to Java, and work on the compiler to support a non-Flash ECMAscript target. There are some high performance ECMAScript engines for Java now, but still it would be a lot of work.

The Laszlo imaging model is pretty easy to support in Java's 2d graphics model.

edutf
05-31-2006, 02:30 PM
I agree with jmcclain, the java enviroment in Laszlo would be awsone, and it also would permit more complex logics in client side, like: enchryption, database access for stand alone applications, access to the hardware devices, etc.

But I agree its a lot of work to make java something native to Laszlo. Scripts are better to UI, and its easier for desginers to learn scripts then java.

I think the key to implement something like that would be a tag similar to html <applet> tag but with no UI in applet. The javascript in HTML can call applets functions and vice versa. The same idea could be used in laszlo.

Or, if we have some improvement in browser integration, it would be possible already. If the LzBrowser had a function to call scripts in HTML, not just loading another page like it works now, but really executing scripts functions in HTML page and returning some value, you could interact with a applet tag and the browser would take care of security stuffs (if applet is signed or not).

These are just some considerations I would like to share, maybe this integration Laszlo/Java wouldnt be that hard to implement.

d~l
06-01-2006, 01:01 AM
" ... If the LzBrowser had a function to call scripts in HTML ...
LzBrowser.loadJS() calls js functions in parent HTML.

edutf
06-01-2006, 09:53 AM
Yeah, it calls a script function in HTML, but I cant get the returned value. It seens like u just load the script into the browser.
To get the result I need to use LzSetCanvasAttribute() in the other side to return something. The problem is that LzSetCanvasAttribute() doesnt call a function, just set attibute already declared in canvas.
If you have to do a lot of calls for different java functions (thru HTML scripts) you would have to implement a complex logic to wait the javascript HTML function return value (you never know when the HTML script is completed) and control multiple calls at the same time.
I did something like that but its kind of hard to control multthread calls in javascript and also we dont have a kind of semaphore or wait functions to optmize the code.
In other words, it works, but its extremely complex and there's no satisfatory performance.

d~l
06-01-2006, 10:32 AM
.. The problem is that LzSetCanvasAttribute() doesnt call a function, just set attibute already declared in canvas. ..

I am now using Flash 8 externalinterface class to call openlaszlo functions (not just set attributes or vars) inside openlaszlo apps.

Try this simple callback (compiled in Flash 8 for externalinterface class to work) ..


<?xml version="1.0" standalone="no"?>
<canvas width="400" height="400" proxied="false" debug="true">
<script>
flash.external.ExternalInterface.addCallback("testing", null, function () {
Debug.write("Hello");
Debug.inspect(canvas);
});

LzBrowser.loadJS('document.getElementById("lzapp").testing()');

</script>
</canvas>