History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-4162
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: -- --
Assignee: Mamye Kratt
Reporter: Max Carlson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Implement <library/> support in DHTML

Created: 18/Jun/07 02:53 PM   Updated: 27/Sep/07 08:55 AM
Component/s: Compiler, Kernel - DHTML
Affects Version/s: Legals
Fix Version/s: RingDing (4.1)

Time Tracking:
Not Specified

Severity: Minor
Fixed in Change#: 5,464
Runtime: N/A
Fix in hand: False


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Max Carlson - 18/Jun/07 02:59 PM
Author: max
Date: 2007-06-18 14:58:11 -0700 (Mon, 18 Jun 2007)
New Revision: 5461

Added:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js
Modified:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/Library.lzs
   openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
   openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java
   openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java
   openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
   openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
   openlaszlo/branches/legals/lps/includes/source/embednew.js
Log:
Change 20070618-maxcarlson-L by maxcarlson@plastik on 2007-06-18 14:06:31 PDT
    in /Users/maxcarlson/openlaszlo/legals-clean
    for http://svn.openlaszlo.org/openlaszlo/branches/legals

Summary: UPDATED: add DHTML loadable library support to server

New Features:

Bugs Fixed:

Technical Reviewer: hminsky
QA Reviewer: ptw
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: compiles a .js library file in the usual place (build/appname/libname.js) . Henry: note that this fails to recompile if the library if compiled in debug mode, it fails on load for a non-debug mode run of the app. Libraries should probably always be compiled as non-debug.

This change implements all the required client code.

Tests: http://localhost:8080/legals-clean/test/snippets/import-view.lzx?lzr=dhtml&lzt=html now runs. http://localhost:8080/legals-clean/test/snippets/import-view.lzx?lzr=dhtml&debug=true followed by http://localhost:8080/legals-clean/test/snippets/import-view.lzx?lzr=dhtml&lzt=html fails.



Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/Library.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/Library.lzs 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/Library.lzs 2007-06-18 21:58:11 UTC (rev 5461)
@@ -12,6 +12,7 @@
 #include "kernel/dhtml/LzKeyboardKernel.js"
 #include "kernel/dhtml/LzMouseKernel.js"
 #include "kernel/dhtml/LzSprite.js"
+#include "kernel/dhtml/LzLibrary.js"
 #include "kernel/dhtml/LzTextSprite.js"
 #include "kernel/dhtml/LzInputTextSprite.js"
 #include "kernel/dhtml/LzXMLParser.js"

Added: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js


Property changes on: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java 2007-06-18 21:58:11 UTC (rev 5461)
@@ -135,7 +135,7 @@
         return compile(sourceFile, objectFile, props);
     }
 
- public String getObjectFileExtensionForRuntime (String runtime) {
+ public static String getObjectFileExtensionForRuntime (String runtime) {
         String ext = SCRIPT_RUNTIMES.contains(runtime) ? ".js" : ".lzr=" + runtime + ".swf";
         return ext;
     }

Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java 2007-06-18 21:58:11 UTC (rev 5461)
@@ -44,6 +44,9 @@
     protected PrintWriter scriptWriter = null;
     protected StringWriter scriptBuffer = null;
 
+ /** Logger */
+ protected static Logger mLogger = org.apache.log4j.Logger.getLogger(DHTMLWriter.class);
+
     DHTMLWriter(Properties props, OutputStream stream,
                 CompilerMediaCache cache,
                 boolean importLibrary,
@@ -328,6 +331,7 @@
 
         try {
             Properties props = (Properties)mProperties.clone();
+ scriptWriter.close();
             byte[] objcode = ScriptCompiler.compileToByteArray(scriptBuffer.toString(), props);
             InputStream input = new ByteArrayInputStream(objcode);
             mLogger.debug("compiled DHTML code is "+new String(objcode));
@@ -341,15 +345,42 @@
         mCloseCalled = true;
     }
 
- public void openSnippet(String url) throws IOException { }
- public void closeSnippet() throws IOException { }
+ public void openSnippet(String url) throws IOException {
+ this.liburl = url;
+ }
 
+ public void closeSnippet() throws IOException {
+ // Callback to let library know we're done loading
+ // TODO [hqm 2007 06] figure out where to get pointer to Library object so
+ // we can call back to it. Key by URL?
+ addScript("LzLibrary.__LZsnippetLoaded('"+this.liburl+"')");
+
+ if (mCloseCalled) {
+ throw new IllegalStateException("DHTMLWriter.close() called twice");
+ }
+
+ try {
+ Properties props = (Properties)mProperties.clone();
+ scriptWriter.close();
+ byte[] objcode = ScriptCompiler.compileToByteArray(scriptBuffer.toString(), props);
+ InputStream input = new ByteArrayInputStream(objcode);
+ mLogger.debug("compiled DHTML code is "+new String(objcode));
+ FileUtils.send(input, mStream);
+ } catch (org.openlaszlo.sc.CompilerException e) {
+ throw new CompilationError(e);
+ } catch (Exception e) {
+ throw new ChainedException(e);
+ }
+
+ mCloseCalled = true;
+ }
+
     /* [todo 2006-02-09 hqm] These methods are to be compatible with
        SWF font machinery -- this should get factored away someday so that the FontCompiler
        doesn't try to do anything with <font> tags in DHTML, (except maybe make aliases for them?)
     */
     FontManager getFontManager() {
- mEnv.warn("DHTML runtime doesn't support FontManager API");
+ // mEnv.warn("DHTML runtime doesn't support FontManager API");
         return null;
     }
 

Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ImportCompiler.java 2007-06-18 21:58:11 UTC (rev 5461)
@@ -91,8 +91,10 @@
             // directly for now.
             String libfile = libsrcfile.getName();
             String libprefix = mEnv.getLibPrefix();
- String objfilename = libprefix + "/" + libfile + ".swf";
- String objpath = mEnv.getLibPrefixRelative() + "/" + libfile + ".swf";
+ String runtime = mEnv.getProperty(mEnv.RUNTIME_PROPERTY);
+ String extension = Compiler.SCRIPT_RUNTIMES.contains(runtime) ? ".js" : ".swf";
+ String objfilename = libprefix + "/" + libfile + extension;
+ String objpath = mEnv.getLibPrefixRelative() + "/" + libfile + extension;
 
             mLogger.info(
 /* (non-Javadoc)
@@ -143,8 +145,19 @@
 
             OutputStream ostream = new FileOutputStream(outfile);
             try {
- ObjectWriter writer = new SWFWriter(env.getProperties(), ostream,
- env.getMediaCache(), false, env);
+ ObjectWriter writer;
+
+ String runtime = env.getProperty(env.RUNTIME_PROPERTY);
+ if (Compiler.SCRIPT_RUNTIMES.contains(runtime)) {
+ writer = new DHTMLWriter(env.getProperties(), ostream,
+ env.getMediaCache(), false, env);
+ } else if (Compiler.SWF_RUNTIMES.contains(runtime)) {
+ writer = new SWFWriter(env.getProperties(), ostream,
+ env.getMediaCache(), false, env);
+ } else {
+ throw new CompilationError("runtime "+runtime+" not supported for generating an import library", element);
+ }
+
                 env.setObjectWriter(writer);
                 // Set the main SWFWriter so we can output resources
                 // to the main app
@@ -159,15 +172,14 @@
                 // copy the fontmanager from old env to new one.
                 writer.setFontManager(mEnv.getGenerator().getFontManager());
                 writer.setCanvasDefaults(mEnv.getCanvas(), mEnv.getMediaCache());
-
                 
- String objpath = mEnv.getLibPrefixRelative() + "/" + outfile + ".swf";
-
                 writer.openSnippet(liburl);
 
                 // allows snippet code to call out to LzInstantiateView in the main app:
                 // var LzInstantiateView = _level0.LzInstantiateView;
- env.compileScript("var "+VIEW_INSTANTIATION_FNAME+" = _level0."+VIEW_INSTANTIATION_FNAME, element);
+ if (Compiler.SWF_RUNTIMES.contains(runtime)) {
+ env.compileScript("var "+VIEW_INSTANTIATION_FNAME+" = _level0."+VIEW_INSTANTIATION_FNAME, element);
+ }
 
                 // Note: canvas.initDone() resets the _lzinitialsubviews list, so
                 // that has to be called when the library finishes loading. This is currently

Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java 2007-06-18 21:58:11 UTC (rev 5461)
@@ -74,6 +74,8 @@
     /** Properties */
     protected Properties mProperties;
 
+ protected String liburl = "";
+
     /** media cache for transcoding */
     protected CompilerMediaCache mCache = null;
 

Modified: openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java 2007-06-18 21:58:11 UTC (rev 5461)
@@ -909,7 +909,6 @@
         mCloseCalled = true;
     }
 
- protected String liburl = "";
     public void openSnippet(String liburl) throws IOException {
         // How do we make sure an initial frame exists? Does this do it?
         Frame frame = mFlashFile.getMainScript().getFrameAt(mLastFrame);

Modified: openlaszlo/branches/legals/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-06-18 21:51:17 UTC (rev 5460)
+++ openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-06-18 21:58:11 UTC (rev 5461)
@@ -203,12 +203,20 @@
     ,/** @access private */
     __dhtmlLoadScript: function (url) {
         var o = '<script type="text/javascript" language="JavaScript1.5" src="' + url +'"></script>';
-
- document.write(o);
         //alert(o);
+ document.writeln(o);
         return o;
     }
 
+ ,__dhtmlLoadLibrary: function (url) {
+ var o = document.createElement('script');
+ o.setAttribute('type', 'text/javascript');
+ o.setAttribute('src', url);
+ document.getElementsByTagName("head")[0].appendChild(o);
+ //alert(o);
+ return o;
+ }
+
     ,/** @access private */
     __getqueryurl: function (url, setglobals) {
         // strip query string to only args required by the compiler


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Max Carlson - 18/Jun/07 03:15 PM
This isn't quite working - dhtml objects aren't instantiating...

Max Carlson - 18/Jun/07 04:35 PM
Author: max
Date: 2007-06-18 16:33:14 -0700 (Mon, 18 Jun 2007)
New Revision: 5464

Added:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/LzLibraryCleanup.lzs
Removed:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzLibraryCleanup.lzs
Modified:
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/Library.lzs
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js
   openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/Library.lzs
Log:
Change 20070618-maxcarlson-K by maxcarlson@plastik on 2007-06-18 15:12:31 PDT
    in /Users/maxcarlson/openlaszlo/legals-clean
    for http://svn.openlaszlo.org/openlaszlo/branches/legals

Summary: Fix instantiation of LzLoader objects

New Features:

Bugs Fixed: LPP-4162 - Implement <library/> support in DHTML

Technical Reviewer: hminsky
QA Reviewer: promanik
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: Moved LzLibraryCleanup.lzs from swf kernel to general kernel. Fixed up library includes.

LzLibrary.js - __LZsnippetLoaded() delegates onload event sending to the LzLibraryCleanup instance for the library.
    

Tests: http://localhost:8080/legals-clean/test/snippets/import-view.lzx?lzr=dhtml&lzt=html and http://localhost:8080/legals-clean/test/snippets/import-view.lzx?lzr=swf7&lzt=html show the text 'loaded'



Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/Library.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/Library.lzs 2007-06-18 22:27:55 UTC (rev 5463)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/Library.lzs 2007-06-18 23:33:14 UTC (rev 5464)
@@ -9,6 +9,7 @@
 
 #include "kernel/LzIdleKernel.lzs"
 #include "kernel/LzUtils.lzs"
+#include "kernel/LzLibraryCleanup.lzs"
 //#include "kernel/LzRequires.lzs"
 if ($dhtml) {
     #include "kernel/dhtml/Library.lzs"

Copied: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/LzLibraryCleanup.lzs (from rev 5461, openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzLibraryCleanup.lzs)

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js 2007-06-18 22:27:55 UTC (rev 5463)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzLibrary.js 2007-06-18 23:33:14 UTC (rev 5464)
@@ -27,7 +27,6 @@
     super.construct.apply(this, arguments);
     this.sprite = new LzSprite(this, false, args);
     LzLibrary.libraries[args.name] = this;
- LzLibrary.__libraryurls[args.href] = this;
 }
 
 /**
@@ -46,11 +45,6 @@
 /**
   * @access private
   */
-static var __libraryurls = [];
-
-/**
- * @access private
- */
 static function findLibrary (libname){
     return LzLibrary.libraries[libname];
 }
@@ -75,7 +69,8 @@
   * @access private
   */
 static function __LZsnippetLoaded (url){
- LzLibrary.__libraryurls[url].onload.sendEvent();
+ // Run the queue to instantiate all pending LzInstantiateView calls.
+ canvas.initDone();
 }
 
 }; // End of LzLibrary

Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/Library.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/Library.lzs 2007-06-18 22:27:55 UTC (rev 5463)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/Library.lzs 2007-06-18 23:33:14 UTC (rev 5464)
@@ -21,7 +21,6 @@
 #include "kernel/swf/LzFunctions.as"
 #include "kernel/swf/LzSoundMC.as"
 #include "kernel/swf/LzLibrary.lzs"
-#include "kernel/swf/LzLibraryCleanup.lzs"
 #include "kernel/swf/LzXMLParser.as"
 #include "kernel/swf/LzXMLTranslator.as"
 #include "kernel/swf/LzHTTPLoader.as"

Deleted: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzLibraryCleanup.lzs


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins


Mamye Kratt - 28/Jun/07 04:56 PM
(4.0 branch (4.0.3) local build r5544)
Closing.


Mamye Kratt - 17/Jul/07 11:40 AM
Close to test in legals.