473,388 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

javascript in java server faces

Hello , everybody I want to know how javascript code can be add in Java Server Faces.
I am trying to do it but gives error .........

i want to add java script code in JSF page page1.jsp
Please help me I am beginner in this field ............thankyou very much

javascriptis given below:



Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2">
  2. grphcs=new Array(6)
  3. Image0=new Image();
  4. Image0.src=grphcs[0]="http://javascriptfreecode.com/images/barg.gif";
  5. Image1=new Image();
  6. Image1.src=grphcs[1]="http://javascriptfreecode.com/images/barg.gif"
  7. Image2=new Image();
  8. Image2.src=grphcs[2]="http://javascriptfreecode.com/images/barg.gif"
  9. Image3=new Image();
  10. Image3.src=grphcs[3]="http://javascriptfreecode.com/images/barg.gif"
  11. Image4=new Image();
  12. Image4.src=grphcs[4]="http://javascriptfreecode.com/images/barg.gif"
  13. Image5=new Image();
  14. Image5.src=grphcs[5]="http://javascriptfreecode.com/images/barg.gif" 
  15.  
  16. Amount=8; //Smoothness depends on image file size, the smaller the size the more you can use!
  17. Ypos=new Array();
  18. Xpos=new Array();
  19. Speed=new Array();
  20. Step=new Array();
  21. Cstep=new Array();
  22. ns=(document.layers)?1:0;
  23. ns6=(document.getElementById&&!document.all)?1:0;
  24.  
  25. if (ns){
  26. for (i = 0; i < Amount; i++){
  27. var P=Math.floor(Math.random()*grphcs.length);
  28. rndPic=grphcs[P];
  29. document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+rndPic+"></LAYER>");
  30. }
  31. }
  32. else{
  33. document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
  34. for (i = 0; i < Amount; i++){
  35. var P=Math.floor(Math.random()*grphcs.length);
  36. rndPic=grphcs[P];
  37. document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px">');
  38. }
  39. document.write('</div></div>');
  40. }
  41. WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
  42. WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
  43. for (i=0; i < Amount; i++){                                                                
  44.  Ypos[i] = Math.round(Math.random()*WinHeight);
  45.  Xpos[i] = Math.round(Math.random()*WinWidth);
  46.  Speed[i]= Math.random()*5+3;
  47.  Cstep[i]=0;
  48.  Step[i]=Math.random()*0.1+0.05;
  49. }
  50. function fall(){
  51. var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight;
  52. var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth;
  53. var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop;
  54. var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft;
  55. for (i=0; i < Amount; i++){
  56. sy = Speed[i]*Math.sin(90*Math.PI/180);
  57. sx = Speed[i]*Math.cos(Cstep[i]);
  58. Ypos[i]+=sy;
  59. Xpos[i]+=sx; 
  60. if (Ypos[i] > WinHeight){
  61. Ypos[i]=-60;
  62. Xpos[i]=Math.round(Math.random()*WinWidth);
  63. Speed[i]=Math.random()*5+3;
  64. }
  65. if (ns){
  66. document.layers['sn'+i].left=Xpos[i];
  67. document.layers['sn'+i].top=Ypos[i]+hscrll;
  68. }
  69. else if (ns6){
  70. document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]);
  71. document.getElementById("si"+i).style.top=Ypos[i]+hscrll;
  72. }
  73. else{
  74. eval("document.all.si"+i).style.left=Xpos[i];
  75. eval("document.all.si"+i).style.top=Ypos[i]+hscrll;
  76. Cstep[i]+=Step[i];
  77. }
  78. setTimeout('fall()',20);
  79. }
  80.  
  81. window.onload=fall
  82. //-->
  83. </script>
  84.  
  85.  
  86. <font face="Tahoma"><a target="_blank" href="http://www.javascriptfreecode.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
Mar 29 '10 #1
3 2843
Dormilich
8,658 Expert Mod 8TB
no wonder it doesn’t work, this code is terribly outdated.

PS. JavaScript is currently at version 1.8 resp. ECMAScript 262 3rd Edition (5th Edition coming up)
Mar 29 '10 #2
thanks for reply...................
is there any way to improve or modify this code so that it can be used with JSF page.............or please tell me the link from with i can get approprivate javascript........again.thankyou very much.........
Mar 31 '10 #3
Dormilich
8,658 Expert Mod 8TB
see this forum’s offsite links.
Mar 31 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: wee | last post by:
I've been using Java for a few years now and am just amazed at how many new "technologies" or tools come out all the time (i.e., Struts, Java Server Faces, JMeter, jad, etc.). It is nigh impossible...
0
by: SP | last post by:
Hello there, I have a custom ASP.Net application. I would like to place custom Java code within ASP.Net. so i would like to follow the approach of creating Java Server Controls and then...
9
by: misdst23 | last post by:
Hi, I know I can call a static java method within javascript by using the <% ... %tags. But how can pass a javascript variable ? function thefunction() { var = javascriptvariable ;
5
by: petermichaux | last post by:
Hi, Some servers return JavaScript as the response to an AJAX request. When the response JavaScript is eval'ed it calls other JavaScript functions already in the browser to update elements, etc....
0
by: ranadhirnag | last post by:
I need to check a property in the javax.faces.component.html.HtmlInputText. If i do it in the following manner,I get things fine:...
1
by: primozr | last post by:
Hi all, I am turning to this forum to get a little help for my non-profitable project. I am using javascript to parse some XML file. XML looks like this <fdrml> <image> <faces> ...
66
by: flarosa | last post by:
Hi, I'm wondering if I can get a reasonably civil (without starting any huge wars) opinion on how server-side PHP compares to server-side Java. I've been strictly a Java developer for almost...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.