Page Fragment / javascript problem.. please help..

I am having a great deal of trouble with a page fragment hopefully someone can help.

I have a page fragment that I am using as a page header and on this page fragment I have a static text component that I want to have display the current time and date. I have a "clock" javascript that I have used on static pages to display the current time but my problem is that I cannot find anyway to have my page fragment call my javascript with a pointer to the static text component for output. I also do not want to use the parent page onLoad directive to call the clock javascript as the pageframent is used as a common header to a large number of pages.. I'd prefer to call the javascript directly from the page fragment.

I am open to other suggestions to how to better do this also.. is there a "dynamic" JSC time component I can place on the page frament that will display the current time (that changes as the minutes tick by) instead of using my old clock script..

Thanks to all in advance..

[1015 byte] By [jasonweisea] at [2007-11-26 15:55:35]
# 1

One suggestion is to use an applet (just in case you don磘 need the data from the clock in your program.)

The other one has to do with storing data I want to show in Page fragments into fields of the SessionBean class. Perhaps wou may find useful to rewrite your script and turn it into a class and make it update the field in the session bean and then bind the StaticText component to the field. This at least will give you the time at the last update.

Finally, problably you just need to insert the javascript in your Page Fragment磗 JSP file. Just click on the jsp button (on top of the design window) and you will be able to edit the JSP file directly (you won't need the static text component.)

Victor_Munoza at 2007-7-8 22:16:19 > top of Java-index,Development Tools,Java Tools...
# 2

Thank you for the suggestions.

The last suggestion is the most apealling to me but my problem is how do I add the javascript directly to the jspf file (keeping in mind it is a page fragment). I have tried everything from static text with escaping turned off to manually creating the <SCRIPT></SCRIPT> information within the jspf file.

I must be missing something sooo obvious but cannot get my head around it.

Also once I have the javascript embeded in the page fragment how do I update the visible components value.. at the moment the line I use to display the time in my static pages is as follows:

document.clockform.clockspot.value = ..........................

if I wanted to update a static text component with an Id=timeStaticText how do I use this from the script. I have tried:

pageFragment1.timeStaticText.value=................

but this doesn't seem to work....

jasonweisea at 2007-7-8 22:16:19 > top of Java-index,Development Tools,Java Tools...
# 3

I hope this will give you a clue. It won't update the the page automatically but shows how to embedd some javascript.

<?xml version="1.0" encoding="UTF-8"?>

<div style="-rave-layout: grid; width: 400px; height: 200px" xmlns:f="http://java.sun.com/jsf/core" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">

<f:subview id="clock"/>

<SCRIPT>

// This displays the current date and the time

var d = new Date();

document.write(d.toLocaleString());

</SCRIPT>

</div>

Victor_Munoza at 2007-7-8 22:16:19 > top of Java-index,Development Tools,Java Tools...