Forum Stats

  • 3,874,176 Users
  • 2,266,677 Discussions
  • 7,911,757 Comments

Discussions

jdev 12.2.1.4 dynamically changing year in output text

User_H6Z6F
User_H6Z6F Member Posts: 355 Bronze Badge

we are using jdev 12.2.1.4 and we want to show copyright and the current year on the footer of the current page.eg

<af:outputText id="footSp" value="Copyright © 2022">

Is there any way by which we can get the year dynamically instead of hardcoding it?

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,919 Red Diamond

    You can you an EL that is pointing to a bean that returns the current year as a string. Like EL:

    <af:outputText id="footSp" value="Copyright © #{Mybean.currentYear}">
    

    and in the MyBean java class

    public String getCurrentYear() {
    // do the calculation to get the current year
    String year = ...
    return year
    }
    

    Now, each time you use this outputtext you get the copyright with the current year.


    Timo

  • User_H6Z6F
    User_H6Z6F Member Posts: 355 Bronze Badge

    @Timo Hahn Thanks for the reply.

    So there is no alternative way to get year from direct EL expression? That way I can avoid bean binding.

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,919 Red Diamond

    Sure, you can create a method in the application module that returns the year. Then you can use the return value inside an EL.

    The solution using a bean is simpler to implement.


    Timo