Sat. Dec 4th, 2021

Requirement: There is a page demo.jsf. In that page we will have an af:outputText. The value in that af:outputText will be the datetime in “” format. Now when the page load it shows value in the af:outputText. Also every second the value should refresh automatically and display the current datetime in the af:outputText at that point of time.

Solution: For solution of the above requirement follow the below steps:

Step 1: Create an Oracle ADF Fusion Web Application.

Step 2: Create a demo.jsf page in the ViewController project of our application created in Step 1

Step 3: Drag and drop af:outputText from the component palette in the demo.jsf page created in Step 2.

Step 4: Drag and drop af:poll from the component palette in the demo.jsf page created in Step 2. From property inspector set interval=”1000″. Create a pollListener of the af:poll from the property inspector of the af:poll. The Bean Name is MyBean, the Class Name is MyBean, the scope of the Managed Bean is backingBeanScope, keep the Package as view, Extends is java.lang.Object. Click OK.

Give the pollListener name as getTime.

Step 5: Set partialTriggers=”p1″ from the property inspector of the af:outputText. This will refresh the af:outputText whenever the af:poll is called.

Step 6: Go to file. Add private String dateTime = null; Generate the accessors for dateTime String.

Step 7: Now go to getTime(PollEvent pollEvent) method in the file and write the below code:

String timeStamp = new SimpleDateFormat("").format(new Date( )); this.setDateTime(timeStamp);

Thus, the complete code is shown below:

Step 8: Go to af:outputText in demo.jsf page. Set the value of the af:outputText as value=”#{backingBeanScope.MyBean.dateTime}”. Thus, the complete demo.jsf page code is shown below:

Step 9: Save all and run the application. The running application is shown as below:

The demo.jsf page is loaded automatically every second and the value in the af:outputText is also getting refreshed.

Hence, the solution to our requirement.

If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.

Thanks & Regards,
Susanto Paul

 460 total views,  1 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *