473,811 Members | 3,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript in java server faces

2 New Member
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 ............tha nkyou 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 2860
Dormilich
8,658 Recognized Expert Moderator Expert
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
vipendra
2 New Member
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.thanky ou very much.........
Mar 31 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
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
3193
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 to keep up on everything. It seems almost like it's a fad in which you've got to know the next new thing or you aren't much. I've always wondered: does the C++ world do this? Are there new libraries coming out all the time, new paradigms, or...
0
1314
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 placing them in ASp.NEt. I read that the equivalent of ASP.NET is Java Server Faces.
9
41723
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
2092
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. This seems like a good system because it allows so much freedom in creating the desired behavior in the browser. The required data doesn't have to be converted to XML or JSON on the server. The browser doesn't have to have templates for...
0
1465
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: if(comp.getClass().getName().equalsIgnoreCase("javax.faces.component.html.HtmlInputText")) { String getter=((javax.faces.component.html.HtmlInputText)comp).getOnfocus(); if(getter!=null) { System.out.println(getter); } }
1
1143
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> <face></face> <face></face>
66
4699
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 10 years now, and I'm pretty happy with it. However, I can't help but notice that there are a significant amount of PHP-based development projects where I live, and I've also noticed when searching around the internet for ready-
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10410
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10138
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.