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

timer in webdynpro

Former Member
0 Likes
650

hi i want code for running timer in webdynpro

it should be in hh:mm:ss

format

thank u

Accepted Solutions (0)

Answers (3)

Answers (3)

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

Former Member
0 Likes

Hi Vani,

Are you talking about the TimedTrigger control

Maybe you can try the following code:


public static void wdDoModifyView(IPrivateView3 wdThis, IPrivateView3.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
	IWDTimedTrigger timeTriggered = (IWDTimedTrigger)view.getElement("TimeTriggered");
	if(wdContext.currentContextElement().getContextAttribute()){
       if(i<10){
    		timeTriggered.setEnabled(false);   	
       }
       }
    //@@end
  }

You also get an action with this which gets called per the delay time.Where your can write the code.

Regards

Amit

Former Member
0 Likes
Former Member
0 Likes

hi ididnt get

in wdyn i took time triggred ui elment

i dont want to enable or hide it shold be running in hh:ss:mm format

i want to access that value while saving rec..

when view loads it shld start running

pls send me code

Former Member
0 Likes

Hi,

1)Insert Timed Trigger UI Element

2)create 1 attribute TIME,set datatype as String.

3)context map this attribute to component controller

4)Insert Textview,then bind that time attribute to textview

5)create action as Time for timed trigger in their properties and also set properties DELAY = 1

6)write code in this, onActionTime(),

String dt1 = Calendar.getInstance().getTime().toString();

wdContext.currentContextElement().setTime(dt1);

Former Member
0 Likes

i got running timer in hh:mm:ss format

i want to extract value at particular instant

i.e current time from timer

how to achieve that