Tuesday, September 25, 2007

Implementing a simple watch in a OA Framework Page

I hope this is interesting ... implementing a watch in OA Framework page.There can be several other functionalities, one can do after implementing this watch.Here i am just writing a simple function for javascript watch,you can take an idea.... and change this function accordingly.

Just read this function.....

/* Here is the javascript function, which is self explainatory
Read this function carefully
to understand it.*/

function update()
//Define a new date object
var today=new Date();

var hours=today.getHours();
var minutes=today.getMinutes();
var seconds=today.getSeconds();

//for formatting output
if (hours<10)
if (minutes<10)
if (seconds<10)

//writing output to message text input

//refreshing ever sec

I hope this clear. Now here are the steps how you can put it in your OA Framework page.Add a message text input to your page, say its id is "OAclockDisplay".

Now add this code in process request of controller of page:

//storing javascript function is a string
// "\" is used as escape character
String s="function update(){var today=new Date();var hours=today.getHours();var minutes=today.getMinutes();var seconds=today.getSeconds();if(hours<10){hours=\"0\"+hours;} if(minutes<10){minutes=\"0\"+minutes;} if(seconds<10){seconds=\"0\"+seconds;} document.getElementById('OAclockDisplay').value=hours+\":\"+minutes+\":\"+seconds;setTimeout(\"update()\",1000);}";

//getting body bean
OABodyBean bodyBean = (OABodyBean)pageContext.getRootWebBean();

//attaching javascript function to page

// calling this function on load of body bean
String javaS = "javascript:update();";

We are done, run this page you will be able to see a watch in oa framework page in that particular message text input.


Chandra said...

Thanks Mukul,Good Article

Mukul said...

Thanks for the comments, dude.

sourabha said...

mukul its great clock,
but iwant to know can we implement it as a Read only MessageTextInput or MessageStyledText or Header

sourabha said...

mukul its great clock,
but iwant to know can we implement it as a Read only MessageTextInput or MessageStyledText or Header

Mukul said...

sourabha ,
For that u need to use raw text bean with same js function, an u can use document.write() to write time in ur recursive function that i have given.


yo_jyo said...

That was pretty cool.

Manju said...

Thanks Mukul,
This is a very helpful article for me.......thanks once again

Manju said...
This comment has been removed by the author.
krish said...

Hi mukul,
could you please tell me how to call a Oracle function from OAF..I am pretty new to OAF

Thanks & Regards

kimberly said...

This blog is very interesting, i liked because show many good new ideas. I must to say it catched my attention. I like to know about everything and i am fan all information. i am a good reader, that´s why i prefer to read this type of blogs, very interesting.
buy viagra

Mukul said...

Thanks Kimberly, will continue to write more informative articles on my blog.

katty said...

I had a terrible experience when i was going to get my house through costa rica homes for sale I had a date with the seller and my watch was delayed and I reached too late, but the seller waited to me, thanks god. Now I prefer a good watch which work very well all the time.

Dipak Oracle Technical Consultant said...

Thanks mukul,
u have done great job but i didnt get where to write the javascript code in oaf
plz help

Pradeep said...

Hai Mukul,
Related to message Choice I am working one requirement.Need to
get the value from one messageChoice and pass to another messageChoice.Whether its possible?

Sridevi K said...

Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at training@oracleappstechnical.com | +91 - 9581017828.