Hey,
I'm using JDev 11.1.1.4 and am facing and issue with javascript in ADF. We have a requirement to run some javascript inline on the page - this javascript is for site reporting functionality and is provided by a third party vendor. The javascript code contains all the <javascript><noscript> tags in it so using <af:resource> isn't really going to work for me.
I understand that the way it is to be used is kind of against how ADF prefers you to run Javascript but in this case I don't really have much of a choice.
A sample of what I have is:
<af:panelGroupLayout id="report-container" layout="vertical">
<af:outputText value="#{attrs.user}" id="dc_ot1" styleClass="user" />
<af:outputText value="#{attrs.page}" id="dc_ot2" styleClass="page" />
<af:outputText escape="false" value="#{bundle.JAVASCRIPT}" id="dc_ot3" visible="false" clientComponent="true"/>
</af:panelGroupLayout>
This snippet is contained in an <af:declarativeComponent> tag that has a partialTrigger on some buttons that load task-flows into a dynamic region. The idea is that every time a task-flow is loaded, the javascript is run/refreshed to do reporting.
The first two outputTexts hold values that are read from the javascript included in #{bundle.JAVASCRIPT}. The two outputTexts refresh fine, i.e. when I click a tab I get the updated values, but the javascript is only ever loaded once (the first time you load the page). I verify this via debug statements in the JS and also alert statements. I have also tried the above solution by putting the javascript in between <![CDATA[]]> tags but I experience the same behaviour. I read a blog from Frank Nimphius (https://blogs.oracle.com/jdevotnharvest/entry/gotcha_when_using_javascript_in) which looked similar to my problem but wrapping it in any kind of panel* component didn't help.
My feeling is that the javascript is being cached or at least not refreshed but I don't know where to go from here. How can I force the javascript rendered on the page page to run each time the <af:declarativeComponent> is refreshed?
I've also tried putting javascript straight onto the page fragment in the task-flow but I experience the same behaviour i.e. javascript is only run once.
You can reproduce this by creating a dynamic region and having two task-flows. On one of the taskflows have a jsff page which an <af:resource> tag and within it just an alert like alert('hello world'). The first time you load the task-flow you will see the alert, but if you go to the second task-flow and then back you won't see the alert.