从jsf页面加载flex swf应用程序

时间:2012-04-19 01:16:04

标签: flash flex jsf swfobject

我正在开发一个JSF应用程序,应该在其上嵌入一个Flex swf对象,但是我无法成功完成它。我现在正在做的是使用Primefaces commandButton,它在click事件上执行javascript函数:

我正在使用的代码如下:

<ui:define name="contentPreview">
    <div style="width: 100%;height: 400px;border: 1px solid;">

    <p:commandButton value="Vista Previa Tour" 
                     process="@this"
                     onclick="loadFlexVirtualTour();"
                      style="float:left;"/>


    <h:panelGroup layout="block" id="flashContent" rendered="true">
               <p>
            To view this page ensure that Adobe Flash Player version 
            11.1.0 or greater is installed. 
        </p>

    </h:panelGroup>

    </div>
</ui:define>

用于加载swf对象的脚本:

<script type="text/javascript">

        function loadFlexVirtualTour(){
        alert(UrlExists("virtualTour.swf"))
        // For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. 
        var swfVersionStr = "10.0.0";
        // To use express install, set to playerProductInstall.swf, otherwise the empty string. 
        swfobject.embedSWF("virtualTour.swf", "flashContent", "400", "400", swfVersionStr);

        // JavaScript enabled so display the flashContent div in case it is not replaced with a swf object.
        swfobject.createCSS("#flashContent", "display:block;text-align:left;");
        }

        function UrlExists(url)
        {
            var http = new XMLHttpRequest();
            http.open('HEAD', url, false);
            http.send();
            return http.status!=404;
        }
    </script>

UrlExists是一个检查给定URL上是否存在资源的函数,在这种情况下,我正在检查virtualTour.swf是否与jsf页面在同一目录中。

该函数执行正确,因为我可以在屏幕上看到警报,甚至URLExists函数返回true。但是,未加载应用程序。我做错了什么......

PD:标签只生成一个html元素,特别是对于这种情况,render html将是

 <button id="j_idt43" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" style="float:left;" onclick="loadFlexVirtualTour();;PrimeFaces.ab({formId:'j_idt8',source:'j_idt43',process:'j_idt43'});return false;" name="j_idt43" role="button" aria-disabled="false">

0 个答案:

没有答案