大家好!

在我的 EOS 项目中,有一个页面流,共三个元素:“开始”---“视图”----“结束”。其中视图与一个jsp文件(A.jsp)关联。

页面流完成的任务是在 jsp 文件呈现的网页上展示一个 flash (一个饼图),控制饼图的数据是在jsp 文件中生成的,然后把数据传递给一个javascript函数,由此函数具体完成flash的展现。

此饼图来自 http://www.fusioncharts.com/Default.asp 为了展现饼图需要下载flash 文件,fusioncharts提供许多种flash。在下面的代码中使用的是Doughnut2D.swf 。因为此论坛的上传附件功能无法使用,所以请想要帮助我的朋友到www.fusioncharts.com/Default.asp下载

FusionCharts v3 (链接就在 FusionCharts v3 Links 下方的 'download')。解压缩后,可以看到 Doughnut2D.swf charts 目录下。使用此flash很简单,直接把它放在 项目的webroot (Eclipse) webcontent (EOS Studio, Web Project) 下即可, 我是把它放在webroot / webcontentcharts目录下。javascript 文件 FusionCharts.js 在JSClass目录下。

我在 Eclipse 中以及在 EOS Studio 建立 Web Project 都是可以通过的。

但在 EOS Studio 建立的EOS项目中建立上述三元素页面流中无法通过。

如果在 A.jsp 文件中 使用 <<script>> ...... <</script>> 调用javascript函数,似乎调用不到 javascript函数。如果使用<<h:script>>调用javascript函数,感觉能够调到 javascript函数。但会出现下列错误

h:script must be empty according to TLD.

请大家帮助。

jsp文件内容如下

ContractedBlock.gifExpandedBlockStart.gifCode<%@ page language="java"contentType="text/html; charset=UTF-8"%><!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"><title>使用字符串充当数据源</title><script language="JavaScript"src="chart/FusionCharts.js"></script></head><body><%String strData="";
      strXML
+="<chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' showValues='0' formatNumberScale='0' showBorder='1'>";
 strXML
+="<set label='Jan' value='462' />";
 strXML
+="<set label='Feb' value='857' />";
 strXML
+="<set label='Mar' value='671' />";
 strXML
+="<set label='Apr' value='494' />";
 strXML
+="<set label='May' value='761' />";
 strXML
+="<set label='Jun' value='960' />";
 strXML
+="<set label='Jul' value='629' />";
 strXML
+="<set label='Aug' value='622' />";
 strXML
+="<set label='Sep' value='376' />";
 strXML
+="<set label='Oct' value='494' />";
 strXML
+="<set label='Nov' value='761' />";
 strXML
+="<set label='Dec' value='960' />";
 strXML
+="</chart>";%><div id="chartDiv"align="center">Chart Container Pie 3D</div><script type="text/javascript">//数据源varmyChart1=newFusionCharts("chart/Doughnut2D.swf","myChartId","600","350");

myChart1.setDataXML("<%=strXML%>");

myChart1.render("chartDiv");</script></body></html>

-----------

javascript 程序 FusionCharts.js  如下所示.

(主要作用是展示一个flash swf文件,具体要展示的swf文件名,包含在上面的jsp 文件中的变量strXML里,并通过 myChart1.render("chartDiv"); 语句传进 javascript 函数)FusionCharts.js 可以在下载的fusioncharts的JSClass目录下找到。

ContractedBlock.gifExpandedBlockStart.gifCode/*
* FusionCharts: Flash Player detection and Chart embedding. 
* Version: 1.2.4 (16th February, 2009) - Added fix for chart with % width/height. 
* Version: 1.2.3 (15th September, 2008) - Added fix for % and & characters. Additional fixes to properly handle double quotes and single quotes in setDataXML() function. 
* Version: 1.2.2 (10th July, 2008) - Added fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions 
* Version: 1.2.1 (21st December, 2007) - Added setting up transparent/opaque mode: setTransparent() function 
* Version: 1.2 (1st November, 2007) - Added FORM fixes for IE 
* Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE 

* Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License: 
* http://www.opensource.org/licenses/mit-license.php 
*
*/if(typeofinfosoftglobal=="undefined")varinfosoftglobal=new
Object();if(typeofinfosoftglobal.FusionChartsUtil=="undefined") infosoftglobal.FusionChartsUtil=newObject(); 
infosoftglobal.FusionCharts
=function
(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){if(!document.getElementById) {return; }//Flag to see whether data has been set initiallythis.initialDataSet=false;//Create container objectsthis.params=newObject();this.variables=newObject();this.attributes=newArray();//Set attributes for the SWFif(swf) {this.setAttribute('swf', swf); }if(id) {this.setAttribute('id', id); }

debugMode=debugMode?debugMode :0;this.addVariable('debugMode', debugMode);

w=w.toString().replace(/\%$/,"%25");if(w) {this.setAttribute('width', w); } 
      h
=h.toString().replace(/\%$/,"%25"
);if(h) {this.setAttribute('height', h); }//Set background colorif(c) {this.addParam('bgcolor', c); }//Set Qualitythis.addParam('quality','high');//Add scripting access parameterthis.addParam('allowScriptAccess','always');//Pass width and height to be appended as chartWidth and chartHeightthis.addVariable('chartWidth', w);this.addVariable('chartHeight', h);//Whether in debug mode//Pass DOM ID to Chartthis.addVariable('DOMId', id);//Whether to registed with JavaScriptregisterWithJS=registerWithJS?registerWithJS :0;this.addVariable('registerWithJS', registerWithJS);//Scale Mode of chartscaleMode=scaleMode?scaleMode :'noScale';this.addVariable('scaleMode', scaleMode);//Application Message Languagelang=lang?lang :'EN';this.addVariable('lang', lang);//Whether to auto detect and re-direct to Flash Player installationthis.detectFlashVersion=detectFlashVersion?detectFlashVersion:1;this.autoInstallRedirect=autoInstallRedirect?autoInstallRedirect:1;//Ger Flash Player versionthis.installedVer=infosoftglobal.FusionChartsUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7) {//Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IEinfosoftglobal.FusionCharts.doPrepUnload=true
      } 
}

infosoftglobal.FusionCharts.prototype=
      setAttribute:
function
(name, value){this.attributes[name]=value; 
      }, 
      getAttribute:
function
(name){returnthis.attributes[name]; 
      }, 
      addParam:
function
(name, value){this.params[name]=value; 
      }, 
      getParams:
function
(){returnthis.params; 
      }, 
      addVariable:
function
(name, value){this.variables[name]=value; 
      }, 
      getVariable:
function
(name){returnthis.variables[name]; 
      }, 
      getVariables:
function
(){returnthis.variables; 
      }, 
      getVariablePairs:
function
(){varvariablePairs=newArray();varkey;varvariables=this.getVariables();for(keyinvariables){ 
                  variablePairs.push(key
+"="+
variables[key]); 
            }
return
variablePairs; 
      }, 
      getSWFHTML:
function
() {varswfNode="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length) {//netscape plugin architectureswfNode='<embed type="application/x-shockwave-flash" src="'+this.getAttribute('swf')+'" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'"'
                  swfNode
+='id="'+this.getAttribute('id')+'" name="'+this.getAttribute('id')+'"'
;varparams=this.getParams();for(varkeyinparams){ swfNode+=[key]+'="'+params[key]+'"'; }varpairs=this.getVariablePairs().join("&");if(pairs.length>0){ swfNode+='flashvars="'+pairs+'"'; } 
                  swfNode
+='/>'

            }
else{//PC IE
swfNode='<object id="'+this.getAttribute('id')+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'">'
                  swfNode
+='<param name="movie" value="'+this.getAttribute('swf')+'" />'
;varparams=this.getParams();for(varkeyinparams) { 
                   swfNode
+='<param name="'+key+'" value="'+params[key]+'" />'

                  }
varpairs=this.getVariablePairs().join("&"
);if(pairs.length>0) {swfNode+='<param name="flashvars" value="'+pairs+'" />';} 
                  swfNode
+="</object>"

            }
return
swfNode; 
      }, 
      setDataURL:
function
(strDataURL){//This method sets the data URL for the chart.//If being set initiallyif(this.initialDataSet==false){this.addVariable('dataURL',strDataURL);//Update flagthis.initialDataSet=true
            }
else
{//Else, we update the chart data using External Interface//Get reference to chart objectvarchartObj=infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));if(!chartObj.setDataURL) 
                  { 
                        __flash__addCallback(chartObj,
"setDataURL"
); 
                  } 
                   
                  chartObj.setDataURL(strDataURL); 
            } 
      },
//This function :
//fixes the double quoted attributes to single quotes//Encodes all quotes inside attribute values//Encodes % to %25 and & to %26;encodeDataXML:function(strDataXML){varregExpReservedCharacters=["\\$","\\+"];vararrDQAtt=strDataXML.match(/=\s*\".*?\"/g);if(arrDQAtt){for(vari=0;i<arrDQAtt.length;i++){varrepStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,""); 
                              repStr
=repStr.replace(/\'/g,"%26apos;"
);varstrTo=strDataXML.indexOf(arrDQAtt[i]);varrepStrr="='"+repStr+"'";varstrStart=strDataXML.substring(0,strTo);varstrEnd=strDataXML.substring(strTo+arrDQAtt[i].length);varstrDataXML=strStart+repStrr+strEnd; 
                        } 
                  } 
                   
                  strDataXML
=strDataXML.replace(/\"/g,"%26quot;"
); 
                  strDataXML
=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25"
); 
                  strDataXML
=strDataXML.replace(/\&/g,"%26"
);returnstrDataXML;

}, 
      setDataXML:function
(strDataXML){//If being set initiallyif(this.initialDataSet==false){//This method sets the data XML for the chart INITIALLY.this.addVariable('dataXML',this.encodeDataXML(strDataXML));//Update flagthis.initialDataSet=true
            }
else
{//Else, we update the chart data using External Interface//Get reference to chart objectvarchartObj=infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id')); 
                  chartObj.setDataXML(strDataXML); 
            } 
      }, 
      setTransparent:
function
(isTransparent){//Sets chart to transparent mode when isTransparent is true (default)//When no parameter is passed, we assume transparent to be true.if(typeofisTransparent=="undefined") { 
                  isTransparent
=true

            }
//Set the property
if(isTransparent)this.addParam('WMode','transparent');elsethis.addParam('WMode','Opaque'); 
      }, 
       
      render:
function
(elementId){//First check for installed version of Flash Player - we need a minimum of 8if((this.detectFlashVersion==1)&&(this.installedVer.major<8)){if(this.autoInstallRedirect==1){//If we can auto redirect to install the player?varinstallationConfirm=window.confirm("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");if(installationConfirm){ 
                              window.location
="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"

                        }
else
{returnfalse
                        } 
                  }
else
{//Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).//So, expect the developers to provide a course of way to their end users.//window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. ");returnfalse
                  }                   
            }
else
{//Render the chartvarn=(typeofelementId=='string')?document.getElementById(elementId) : elementId;//If loaded in IE and scaleMode and width/height specified in %, load the chart using onload eventif(this.getVariable('scaleMode').search(/noscale/i)>=0&&(this.getAttribute('width').search("%")>0||this.getAttribute('height').search("%")>0) ) 
                  {
//store current object reference
varobj=this;if(window.addEventListener) {//add onload event on firefoxwindow.addEventListener("load",function() 
{ n.innerHTML
=obj.getSWFHTML(); },false
); 
                        }
elseif
(window.attachEvent) {//add onload event on IEwindow.attachEvent("onload",function() 
                                    { n.innerHTML
=
obj.getSWFHTML(); } ); 
                        }
else
{//if all onload fails failsn.innerHTML=this.getSWFHTML();             
                        }                         
                  }
else
{//Normal case. Instantly load the chartn.innerHTML=this.getSWFHTML(); 
                  }
//Added <FORM> compatibility
//Check if it's added in Mozilla embed array or if already exitsif(!document.embeds[this.getAttribute('id')]&&!window[this.getAttribute('id')]) 
                   window[
this.getAttribute('id')]=document.getElementById(this.getAttribute('id'
));//or else document.forms[formName/formIndex][chartId]returntrue;             
            } 
      } 
}
/*---- detection functions ----*/
infosoftglobal.FusionChartsUtil.getPlayerVersion=function(){varPlayerVersion=newinfosoftglobal.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){varx=navigator.plugins["Shockwave Flash"];if(x&&x.description) { 
                  PlayerVersion
=newinfosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."
)); 
            } 
      }
elseif(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0
){//If Windows CEvaraxo=1;varcounter=3;while(axo) {try
                        counter
++

                        axo
=newActiveXObject("ShockwaveFlash.ShockwaveFlash."+
counter); 
                        PlayerVersion
=newinfosoftglobal.PlayerVersion([counter,0,0
]); 
                  }
catch
(e) { 
                        axo
=null

                  } 
            } 
      }
else
{//Win IE (non mobile)//Do minor version lookup in IE, but avoid Flash Player 6 crashing issuestry{varaxo=newActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); 
            }
catch
(e){try{varaxo=newActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); 
                        PlayerVersion
=newinfosoftglobal.PlayerVersion([6,0,21
]); 
                        axo.AllowScriptAccess
="always";//error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
}catch(e) {if(PlayerVersion.major==6) {returnPlayerVersion; 
                        } 
                  }
try

                        axo
=newActiveXObject("ShockwaveFlash.ShockwaveFlash"
); 
                  }
catch
(e) {} 
            }
if(axo!=null
) { 
                  PlayerVersion
=newinfosoftglobal.PlayerVersion(axo.GetVariable("$version").split("")[1].split(","
)); 
            } 
      }
return
PlayerVersion; 

infosoftglobal.PlayerVersion
=function
(arrVersion){this.major=arrVersion[0]!=null?parseInt(arrVersion[0]) :0;this.minor=arrVersion[1]!=null?parseInt(arrVersion[1]) :0;this.rev=arrVersion[2]!=null?parseInt(arrVersion[2]) :0
}
//------------ Fix for Out of Memory Bug in IE in FP9 ---------------//
/*Fix for video streaming bug*/infosoftglobal.FusionChartsUtil.cleanupSWFs=function() {varobjects=document.getElementsByTagName("OBJECT");for(vari=objects.length-1; i>=0; i--) { 
            objects[i].style.display
='none'
;for(varxinobjects[i]) {if(typeofobjects[i][x]=='function') { 
                        objects[i][x]
=function
(){}; 
                  } 
            } 
      } 
}
//Fixes bug in fp9
if(infosoftglobal.FusionCharts.doPrepUnload) {if(!infosoftglobal.unloadSet) { 
            infosoftglobal.FusionChartsUtil.prepUnload
=function
() { 
                  __flash_unloadHandler
=function
(){}; 
                  __flash_savedUnloadHandler
=function
(){}; 
                  window.attachEvent(
"onunload"
, infosoftglobal.FusionChartsUtil.cleanupSWFs); 
            } 
            window.attachEvent(
"onbeforeunload"
, infosoftglobal.FusionChartsUtil.prepUnload); 
            infosoftglobal.unloadSet
=true

      } 
}
/*Add document.getElementById if needed (mobile IE < 5)*/
if(!document.getElementById&&document.all) { document.getElementById=function(id) {returndocument.all[id]; }}/*Add Array.push if needed (ie5)*/if(Array.prototype.push==null) { Array.prototype.push=function(item) {this[this.length]=item;returnthis.length; }}/*Function to return Flash Object from ID*/infosoftglobal.FusionChartsUtil.getChartObject=function(id) 
{
varchartRef=null
;if(navigator.appName.indexOf("Microsoft Internet")==-1) {if(document.embeds&&document.embeds[id]) 
chartRef
=
document.embeds[id];elsechartRef=window.document[id]; 
}
else

chartRef
=
window[id]; 
}
if(!
chartRef) 
      chartRef
=
document.getElementById(id);returnchartRef; 
}
/*Aliases for easy usage*/
vargetChartFromId=infosoftglobal.FusionChartsUtil.getChartObject;varFusionCharts= infosoftglobal.FusionCharts;

转载于:https://www.cnblogs.com/cy163/archive/2009/11/13/1602784.html

EOS project 中 的一个 jsp 文件中 调用 javascript函数的问题相关推荐

  1. linux强制移除pdf密码,分享|如何在 Linux 中从一个 PDF 文件中移除密码

    今天,我碰巧分享一个受密码保护的 PDF 文件给我的一个朋友.我知道这个 PDF 文件的密码,但是我不想透露密码.作为代替,我只想移除密码并发送文件给他.我开始在因特网上查找一些简单的方法来从 PDF ...

  2. Java main方法_解释Java中的main方法,及其作用_一个java文件中可包含多个main方法

    public static void main(String[] args) {} 或者 public static void main(String args[]) {} main方法是我们学习Ja ...

  3. 如何避免JSP文件中的Java代码?

    本文翻译自:How to avoid Java code in JSP files? I'm new to Java EE and I know that something like the fol ...

  4. java怎么创建jsp文件怎么打开_Eclipse中怎么创建jsp文件?

    创建jsp文件的方法:首先打开Eclipse:然后点击菜单栏的"File",并选"New":接着选择"Dynamic Web Project" ...

  5. javaWeb 中Tomcat 10 jsp文件内置对象不能正常使用的问题(已解决)

    在这段时间学习javaweb时,因为是自己找的视频,下载了最新版本的Tomcat,Tomcat 10 ,然后就发现了很多问题,Tomcat 10 跟之前的版本 有很大的区别,以至于,10以下的版本的文 ...

  6. 如何才能在jsp文件中使用el表达式

    jsp引入el表达式 1.需要的jar包 jstl.jar standard.jar 2.创建一个jsp文件如下 <%@ page language="java" conte ...

  7. java访问本地文件_详解Java读取本地文件并显示在JSP文件中

    详解Java读取本地文件并显示在JSP文件中 当我们初学IMG标签时,我们知道通过设置img标签的src属性,能够在页面中显示想要展示的图片.其中src的值,可以是磁盘目录上的绝对,也可以是项目下的相 ...

  8. 是否可以在另一个CSS文件中包含一个?

    是否可以在另一个CSS文件中包含一个? #1楼 是的,可以使用@import并提供css文件的路径,例如 @import url("mycssfile.css"); 要么 @imp ...

  9. 调用另一个python文件中的代码

    python3.*版本下好像不一样,正确引用方法: utils是同级目录,options是文件,后面是函数 from .utils.options import parseOptions from . ...

最新文章

  1. MySQL添加用户、删除用户与授权
  2. 使用onclick跳转到其他页面。使用button跳转到指定url
  3. html导出pdf实例,jsPDF导出pdf示例
  4. JQuery 实践--让页面动起来
  5. 多个key作为参数进行删除_作为开发人员这些Redis基础应该掌握
  6. 2017 Multi-University Training Contest - Team 5:1001. Rikka with Candies(手写bitset)
  7. DHCP+NAT+IP隧道
  8. 辩证的看DIV+CSS与TABLE
  9. 基于Android Studio的游戏开发-横版格斗.part
  10. PATH=ASSA脚本学习区
  11. c语言同构数循环,C语言求同构数.pdf
  12. python语音聊天_语音聊天实现
  13. 用七段数码管显示学号python_用七段数码管显示学号python
  14. 怎么推广引流?利用B站短视频上热门技巧轻松吸粉
  15. 2013年各大小IT公司待遇,绝对真实,一线数据!(初版)
  16. 【地理人工智能交叉】通过整合兴趣点和Word2Vec模型感知城市土地利用的空间分布
  17. 2010年下半年 系统集成项目管理工程师 下午试卷
  18. 什么是目标检测中的平均精度均值(mAP)?
  19. (1)声明一个圆柱体类型,(2)声明属性:底边的半径,和高(3)声明方法:A:方法的功能:在方法中打印圆柱体的详细信息:圆柱体的底边的半径是xxx,高是xxx,底面积是xxx,体积是xxx。B
  20. Android 百度地图之路径规划

热门文章

  1. neo4j limit
  2. requests与bs4编码
  3. Oracle的distinct关键字
  4. 利用数据缓存加速文件备份
  5. Myeclipse学习总结(9)——MyEclipse2014安装插件的几种方式(适用于Eclipse或MyEclipse其他版本)
  6. 三星active2怎么连接手机_手机怎么连接隐藏的wifi无线网络
  7. php判断参数_php如何判断有没有参数
  8. mysql 39 t.id 39_ERROR 2003 (HY000): Can#39;t connect to MySQL server on #39;10.16.115.101#39; (1...
  9. Idea启动报错 Error:java: System Java Compiler was not found in classpath
  10. 自定义应用程序配置文件(app.config)