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

Key: LPP-4084
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: -- --
Assignee: Frisco Del Rosario
Reporter: Dante Aligerri
Votes: 1
Watchers: 2
Operations

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

loading code with import-tag in ol application in a diffrent webcontext don´t work

Created: 04/Jun/07 02:18 AM   Updated: 27/Sep/07 08:55 AM
Component/s: Components - base
Affects Version/s: 4.0.0
Fix Version/s: RingDing (4.1)

Time Tracking:
Not Specified

Environment: Ubuntu 7.04, Windows XP, Flash 9, Resin 3.14, Tomcat 5.0.24

Severity: Blocker
Fixed in Change#: 5,502
Runtime: N/A
Fix in hand: False


 Description  « Hide
I´ve got two webcontexts LPS -> where the ol-application in,
and TEST -> where the html-file with a embedded-tag which calls the ol-app. in.
The ol-app. contains a import-tag.
When I would like to load the imported code in the ol-app, the request goes to the wrong webcontext,
in this case TEST!
If the html-file is in the same webcontext if worke fine.

See also in ol-forum: http://forum.openlaszlo.org/showthread.php?t=8879. In this thread you will find a testcase
which i created for this problem.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
P T Withington - 06/Jun/07 01:58 PM
[16:55] p7w: I'm afraid of this reporter: Dante Aligerri !
[16:56] maxcarlson: well, it will be important for hosted components.
[16:56] p7w: soo... confirm to you?
[16:56] maxcarlson: doe! sure.
[16:57] p7w: or you want frisco to reproduce and add test case first?
[16:57] mamye: Needs a fix version too. :-)
[16:57] maxcarlson: yes!
[16:57] jsundman joined the chat room.
[16:57] frisco: Okeydoke.
[16:57] maxcarlson: fix 4.0.3?

Henry Minsky - 08/Jun/07 08:10 AM
I did a test where I created the app in a legals webcontext named /legals3
and tried to load from an HTML wrapper defined in another legals context mounted at /legals2


I used this wrapper derived from the lzt=html wrapper, and changed the pathnames for the embed.js and the url arg to swfEmbed
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <link rel="SHORTCUT ICON" href="http://www.laszlosystems.com/favicon.ico"><title>OpenLaszlo Application</title><script type="text/javascript">
          // If loaded bare into a browser, set the browser size to the canvas size
          if (window === top) {
            (function (width, height) {
              // Cf. http://www.quirksmode.org/viewport/compatibility.html
              if (window.innerHeight) {
                // Sadly, innerHeight/Width is not r/w on some browsers, and resizeTo is for outerHeight/Width
                window.resizeTo(width ? (width + window.outerWidth - window.innerWidth) : window.outerWidth,
                                height ? (height + window.outerHeight - window.innerHeight) : window.outerHeight);
              } else if (document.documentElement && document.documentElement.clientHeight) {
                if (width) {
                  document.documentElement.clientWidth = width;
                }
                if (height) {
                  document.documentElement.clientHeight = height;
                }
              } else {
                if (width) {
                  document.body.clientWidth = width;
                }
                if (height) {
                  document.body.clientHeight = height;
                }
              }
            })(800, 600);
          }
        </script><script type="text/javascript">
            lzOptions = { ServerRoot: '/legals3'};
        </script><script type="text/javascript" src="/legals3/lps/includes/embed-compressed.js"></script><style type="text/css">
         html, body
         {
         /* http://www.quirksmode.org/css/100percheight.html */
         height: 100%;
         /* prevent scrollbars */
         margin: 0;
         padding: 0;
         border: 0 none;
         overflow: hidden;
         }
         body {
                background-color: #ffffff;
            }
        
         img { border: 0 none; }
        </style></head><body><script type="text/javascript">
              Lz.swfEmbed({url: '/legals3/test/dante/main.lzx?lzt=swf', bgcolor: '#ffffff', width: '800', height: '600', id: 'lzapp', accessible: 'false'});
            </script><noscript>
            Please enable JavaScript in order to use this application.
        </noscript></body></html>


The library would not load, it seems due to the fact that we compile in a ImportAssets tag which has a hardcoded URL in it.
That ImportAssets code was put in to allow fonts to be imported, but it looks like it's a bad idea to have the
URL hardcoded into to swf file. I don't see any way around that right now but below is a workaround that will probably
work for almost all cases, where people are not trying to import fonts at runtime.

I have a patch which will remove the ImportAssets instruction if there are no imported font resources in the library.

It is going out for review now.

Jens Gross - 21/Jun/07 08:29 AM
I found a workaround for the problem with importing fonts across 2 different webcontexts. It's not perfect, but maybe the OL developers can pick up the idea and modify the source, that the import can be used in a more flexible way.
Here's my code:

Project: LPS
Branch: legals
Revisoin: 5461
File: org.openlaszlo.compiler.SWFWriter.java
Method: public void closeSnippet() throws Exception
------------------- snip --------------------
if (mLibFontsDefined) {
ImportAssets2 ia = new ImportAssets2();
//System.err.println("setting ImportAssets url="+this.liburl);
                      //get property of base url for fonts to import
String importFontUrlPath = System.getProperty("import.font.base.url");
if (importFontUrlPath != null) {
if (importFontUrlPath.endsWith("/") == false) {
importFontUrlPath += "/";
}
if (liburl.startsWith("/")) {
         liburl = liburl.substring(1);
         }
liburl = importFontUrlPath + liburl;
}
ia.setUrl(liburl);

Enumeration enu = mFlashFile.definitions();
while (enu.hasMoreElements()) {
FlashDef def = (FlashDef) enu.nextElement();
ia.addAsset(def.getName(), def);
//System.err.println("adding def named "+def.getName()+ "[id="+def.getID()+"] to ImportAssets2 defs");
}
        
Timeline timeline = mFlashFile.getMainScript().getTimeline();
Frame frame = timeline.getFrameAt(timeline.getFrameCount() - 1);
frame.addFlashObject(ia);
        }
        mLibFontsDefined = false;
------------------- snip --------------------

Henry Minsky - 22/Jun/07 10:09 AM
checked into legals. The workaround suggested in the bug report was implemented using

LPS.getProperty("import.font.base.url");

So the developer can define this in their lps.properties file


Mamye Kratt - 16/Jul/07 04:03 PM
Please test in 4.0.3.