Show current Date and Time on Page in Oracle ADF (refresh Date/time Programmatically)

Sharing is Caring

Hello All,
In this tutorial, I am going to explain that how to show current date and time on page in your Oracle ADF application.

Follow these Steps-

  • Create a fusion web application and a page in it (i have used .jspx page)
  • Now drag an output text from the component palette and drop it on page

 

  • Now select the output text and go to its property inspector then select the value from Expression Builder as shown in the image
    • Now in Expression Builder, create a Managed Bean of type java.util.Date and assign its value to output text

 

  •  Now run your page and see the current date is there
  • Now to format Date and Time , drag and drop af:convertDateTime  under output text from the component palette

 

  •  Select convertDateTime and go to property inspector and change its pattern and run your page

 

 

Show current Date and Time
  •  Now you have done basic configuration for Date/Time, if you want to refresh time (second and minute part) on page periodically then drop a poll component in the page and create a poll listener in the managed bean
    • Now write this simple code in your managed bean to invoke poll listener

    /**Binding of Output text*/
    private RichOutputText dateBind;

    public void setDateBind(RichOutputText dateBind) {
        this.dateBind = dateBind;
    }

    public RichOutputText getDateBind() {
        return dateBind;
    }

    /**Poll Listener Method ,handles Poll Event
 * @param pollEvent
 */
    public void refreshTime(PollEvent pollEvent) {
AdfFacesContext.getCurrentInstance().addPartialTarget(dateBind);

    }

And don’t forget to set clientComponent property of outputText to true

  • Now Run your application, see in this video clip how your page gets refreshed.

 

Cheers 🙂 Happy Learning

Related Posts

I’m an Oracle ACE, Blogger, Reviewer,
Technical Lead working on Oracle ADF

0 thoughts on “Show current Date and Time on Page in Oracle ADF (refresh Date/time Programmatically)”

Leave a Reply

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