cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

timer in webdynpro

Former Member
0 Likes
654

hi i want code for running timer in webdynpro

it should be in hh:mm:ss

format

thank u

View Entire Topic
Former Member
0 Likes

Hi,

<b>I dont know why the post is getting into this format.</b>

In webdynpro their is no option to show time in hh:mm:ss.

But then you can do this with IFrame.

1. Create a IFrame UI element.

2. Create a context attribute say Time of type String. Map this attribute to the source property of IFrame.

3. create a html file (Clock.html) with following content

<HTML>

<BODY onLoad="clock()">

<span id="pendule" style="position:absolute;left:300;top:20;"></span>

<SCRIPT LANGUAGE="JavaScript">

function clock() {

if (!document.layers && !document.all) return;

var digital = new Date();

var hours = digital.getHours();

var minutes = digital.getMinutes();

var seconds = digital.getSeconds();

var amOrPm = "AM";

if (hours > 11) amOrPm = "PM";

if (hours > 12) hours = hours - 12;

if (hours == 0) hours = 12;

if (minutes <= 9) minutes = "0" + minutes;

if (seconds <= 9) seconds = "0" + seconds;

dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;

if (document.layers) {

document.layers.pendule.document.write(dispTime);

document.layers.pendule.document.close();

}

else

if (document.all)

pendule.innerHTML = dispTime;

setTimeout("clock()", 1000);

}

</SCRIPT>

</BODY>

</HTML>

4. Place the html in the src\mimes\Components\<your component>\Clock.html of your

project in your workdpace

3. In wdDoinit of your view controller,

try{

String Url =

DURLGenerator.getWebResourceURL(wdComponentAPI.getComponent().getDeployableObject

art(),"Clock.html");

wdContext.currentContextElement().setTime(Url);

}catch(WDURLException e)

{

wdComponentAPI.getMessageManager().reportException(e.getMessage(),true);

}

Note: Set the property of the IFrame as per requirement so that the time is

displayed at the right position<b></b>

Message was edited by:

Shriram Kabra

Message was edited by:

Shriram Kabra

Former Member
0 Likes

hi when i execute code with html

its not displaying

time

Former Member
0 Likes

hi i got running timer

how to get value of that

ex if i take context of that

it will give running time

i want to extract current time

how to achieve that

Former Member
0 Likes

Hi,

If you have got the running timer through html then it is difficult or not possible to get that time value in the context.

And more over when the person tries to save the data the time on the desktop and the time it saves are different.I mean their would be difference of seconds.

Since you need the current time to save data you can use a different approach.

In the action save use the following code to get the current time in hh:mm:ss format and set this to the context attribute which holds time for saving.

Once the data is saved while showing the message for successful save show the time also.

Date date = new Date(System.currentTimeMillis());

SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");

String s = formatter.format(date);

Set the value of String "s" to the context attribute.

Former Member
0 Likes

hi

i want to print that running time value

if u assign directly it gives running timer

i want value at that point ex while saving

Former Member
0 Likes

i got time in hh:mm:ss format without using html

i am getting that in context i need to extract value at that point