on ‎2007 Jun 15 9:08 AM
hi i want code for running timer in webdynpro
it should be in hh:mm:ss
format
thank u
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check the below link u get an code for timer,
http://help.sap.com/saphelp_nw70/helpdata/en/53/7bfa40badbf56fe10000000a1550b0/frameset.htm
Timed Trigger,
http://help.sap.com/saphelp_nw70/helpdata/en/da/a6884121a41c09e10000000a155106/frameset.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
| User | Count |
|---|---|
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.