简体   繁体   中英

How can I output System.currentTimeMillis() to an ADF page?

I'm using this and it doesn't work as expected. I'm trying to cache bust a css file as it changes a lot and we can't always expect users to thoroughly clear their cache.

  <c:set var="buster" value="{System.currentTimeMillis()}" />
  <af:resource type="css" source="/oracle/webcenter/portalapp/shared/css/maaui.css?r=${buster}"/>

Unfortunately that renders

<link rel="stylesheet" type="text/css" afrres="true" href="/myAccount/oracle/webcenter/portalapp/shared/css/maaui.css?r=%7BSystem.currentTimeMillis()%7D">

It doesn't execute the method. I tried ${} and #{} as well and neither seem to work for me. Can anyone help me to achieve the desired result? Basically a random string that will change each time a user visits a page. I can easily do this in .NET but I am very new to Oracle ADF.

Try

<c:set var="buster" value="{myBean.time}" />

<af:resource type="css" source="/oracle/webcenter/portalapp/shared/css/maaui.css?r=#{buster}"/>

And in MyBean managed backing bean

public long getTime()
{
return System.getCurrentTimeMillis();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM