Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HTMLFlow - problem in script include

    Hi,

    I am using HTMLFlow with contentsURL. The returned content contains scripts, only part of them is evaluated. Here are details:

    in GWT entry point:
    Code:
            HTMLFlow htmlFlow = new HTMLFlow();
            htmlFlow.setWidth(230);
            htmlFlow.setEvalScriptBlocks(true);
            htmlFlow.setContentsURL("test.html");
    in test.html:
    Code:
    <script type="text/javascript" >
    alert(1);
    </script>
    
    <script type="text/javascript">
    alert(2);
    </script>
    
    <script type="text/javascript" src="/js/test.js"></script>
    The problem is that second alert isn't shown. It is solved if I move the last line (external script include) to the beginning.
    Is it a known problem? It has a general solution?

    P.S.
    I think there is a problem in HTMLFlow.js: getScript function.
    (scripts[] and scriptIncludes[] arrays are not in the same sizes, but loadedRemoteScriptBlock gets i (index inside scriptIncludes[]) and removes item from scripts[]). I've got a fix for it, is it possible to enter it?

    thanks a lot
    Last edited by la123; 8 Feb 2009, 06:31.

    #2
    Good catch :) Normally, scriptIncludes[], scripts[] and htmlRemaining[] all contain the same number of elements, but in one specific case scripts[] and scriptIncludes[] become different sizes, which your test hits.

    This fix will be applied to the SmartClient sources, in HTMLFlow.getScript(), which you can apply yourself before the fix hits the SmartGWT builds:

    Code:
    if (isJS) {
        var srcMatch;
        if (srcMatch = scriptStartTag.match(/src=('|")?([^'"> ]*)/i)) {
            scriptIncludes.add(srcMatch[2]);
            scripts.add(null);
        } else { 
            // avoid empty script blocks which can lead to hangs
            if (!isc.isA.String(scriptBlock) || isc.isAn.emptyString(scriptBlock)) continue;
            // slot this script into our script accumulator
            scripts.add(scriptBlock);
    [b]+        scriptIncludes.add(null);[/b]
        }
        htmlFragments.add(null);
    } else {
    Thank you.

    Comment

    Working...
    X